LDraw.org Discussion Forums
BBCode tag for inserting a part image - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: Administrative (https://forums.ldraw.org/forum-4.html)
+--- Forum: Website Suggestions/Requests/Discussion (https://forums.ldraw.org/forum-23.html)
+--- Thread: BBCode tag for inserting a part image (/thread-3908.html)



BBCode tag for inserting a part image - Orion Pobursky - 2012-03-20

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.

Example:
[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.


Re: BBCode tag for inserting a part image - Steffen - 2012-03-21

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]
?


Re: BBCode tag for inserting a part image - Philippe Hurbain - 2012-03-21

Do you intend to make it work too for subparts/primitives?


Re: BBCode tag for inserting a part image - Orion Pobursky - 2012-03-21

I was planning on it.


Re: BBCode tag for inserting a part image - Steffen - 2012-03-21

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


Re: BBCode tag for inserting a part image - Orion Pobursky - 2012-03-21

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.


Re: BBCode tag for inserting a part image - Orion Pobursky - 2012-03-23

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?


Re: BBCode tag for inserting a part image - Chris Dee - 2012-03-24

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?


Re: BBCode tag for inserting a part image - Orion Pobursky - 2012-03-24

Yeah:
48/5-48chrd.dat