Forums / Setup & design / HowTo see if article has an image
John van der Boom
Sunday 10 August 2003 8:29:29 am
I want to test if an article has an article in it.If it do not I want to put a standard image
{section name=show_image show=null($content_version.data_map.thumbnail.id)} <img src={"standard.gif"|ezimage} width="190" height="136" /> {section-else} {attribute_view_gui attribute=$content_version.data_map.thumbnail image_class=medium}{/section}
I'm testing to see if thumbnail_object has an id. But it seems like it the thumbnail_object always has an ID, even if I dont put an image....
Is there a "correct" way to test if the article has an image?
Selmah Maxim
Sunday 10 August 2003 9:34:40 am
try this :
{section show=is_object($content_version.data_map.thumbnail)} {attribute_view_gui attribute=$content_version.data_map.thumbnail image_class=medium}{/section}
Sunday 10 August 2003 10:59:25 am
Hey Selmah,
I tried this: {section show=is_object($content_version.data_map.thumbnail)} {attribute_view_gui attribute=$content_version.data_map.thumbnail image_class=medium} {section-else} <img src={"informe.gif"|ezimage} width="190" height="136" />{/section}
But still it won't work so I tested what the operator "is_object" is returning as value for a new article without an image with:
{default content_version=$node.contentobject_version_object}{is_object($content_version.data_map.thumbnail)}
and it turned out that the value is 1 (true).And this should be 0 (false) becasue there is no image attached to the image :(
Bjørn Kaarstein
Sunday 10 August 2003 10:31:08 pm
This one works for me:
{section show=ne($:item.data_map.picture.content)}
<img src={$:item.data_map.picture.content[original].full_path|ezurl} hspace="10" vspace="10" border=0 align=right>
{/section}
I can't really see the logic here, becuse I would assume that the show= should contain eq instead of ne. Anyway, this runs smoothly within a loop.
Regards Bjørn
Monday 11 August 2003 1:42:31 am
{$:item.data_map.thumbnail.content}
This is not working for me either.
I tried to echo the value for different article (with and without image) and for all of them, the value of content is "null". So the value is not set.
What is happening here?
Monday 11 August 2003 5:57:54 am
Found the correct code:
{section show=is_object($content_version.data_map.thumbnail.content)} {attribute_view_gui attribute=$content_version.data_map.thumbnail image_class=medium} {section-else} <img src={"standard.gif"|ezimage} width="190" height="136" />{/section}
As you can see I combined both of your tips and came with this. It's working perfectly.How can I add this to the documentation?