Attribute help

Permalink
Hello

I am using the following code below to pull through an image to one of my templates. The only issue is that if you do not insert an image when you create the page and go to edit the page, the header bar doesn't load and only have the page loads. I know why it is happening but what code do I put in order for the page to continue loading even if an image has been inserted.

<img src="<?php echo ($c->getAttribute('thumbnail')->getVersion()->getRelativePath());?>" width="160px">


thanks M

agentorange
 
adajad replied on at Permalink Reply
adajad
I would do this:
<?php
$thumbnail = $c->getAttribute('thumbnail')->getVersion()->getRelativePath();
if ($thumbnail) { ?>
    <img src="<?php echo $thumbnail ?>" width="160px">
<?php } ?>
//rest of code


EDIT: I just remembered I wrote a how-to on this (sort of) a while ago: http://www.concrete5.org/documentation/how-tos/designers/use-attrib...