LDraw.org Discussion Forums

Full Version: BBCode tag for inserting a part image
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been working on a simple extension to learn the ropes of module creation for the Forums. I choose something simple that I thought would be useful, a BBCode tag to insert a part image based on the number.

[datimage 3001.dat]

Here's my hang up: how to handle official/unofficial parts. I've changed my mind several times on this so I thought I'd open it up for discussion instead of imposing my will on everyone else. What I have now is this:
[datimage unofficial 3001.dat]
If unofficial is left out the code assumes you want the official image.

Also, I'd like to have the default output be nothing if the part referenced doesn't exist. I'm not quite sure how to test for a broken link with PHP so if anyone can help me out, that would be awesome.
I find the "datimage" token somewhat artificial and hard to remember.
Since the tag is intended to be human-written, why not use something more easily understood and remembered,
like e.g.
[official part 3001.dat]
[unofficial part 3001.dat]
Do you intend to make it work too for subparts/primitives?
I was planning on it.
then maybe this
[official file 3001.dat]
[unofficial file 3001.dat]
[official file s\3001s01.dat]
[unofficial file s\3001s01.dat]
could be a better idea
Well if I can figure out how to test for a nonexistent link in PHP the the whole official/unofficial thing become obsolete. I can just check if the image exists officially and fail to unofficial or nothing if it doesn't. I could then just add a modifier if you want the pic of the PT version of he file if, for example, the part is under revision and you want to show the revised version.
Ok got it working the way I'd like. Stackoverflow is awesome.
I think I'm going to go with ldraw_part. I found out that we only have official images of part and not primitives and subparts. Since that's the case I'm going to have the code default to a text link if no image is present. Since I'm already linking text, I decided to link images as well with the official images linking to the official part and the unofficial images linking to the PT page.

Since some primitive images are very small (2x2 px), I'm thinking about having them be a text link all the time. Thoughts?
Orion Pobursky Wrote:Since some primitive images are very small (2x2 px), I'm thinking about having them be a text link all the time. Thoughts?

They shouldn't be small. The PT image generation renders most primitives larger than regular parts. Only stug* primitives are not magnified. Do you have an example?