Image Attribute in template

Permalink
Hi,
I have an image attribute hardcoded like so in template files:

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


everything is fine except when editing page defaults, the whole C5 layout (top bar and everything related to C5 logged in) disappears.

Is there something wrong with my code? How can I resolve this without having to delete that line from the template everytime I need to go and edit the page defaults?

Any light on this matter would be much appreciated.
Thanks

GBNT
 
irsah replied on at Permalink Reply
irsah
Hi GBNT,

Oh scratch that answer i totally switched to the image helper due to certain $c calls in default pagetype. My bad. It breaks when editing default pages. I'm outside and i'll post if i get the chance.

regards.
GBNT replied on at Permalink Reply
GBNT
Hmm. no luck with that either...
I think the problem is, in defaults, as there is no image added, the page breaks.

How would I wrap it around something to check if there is an an image attributed, and if it doesn't, to ignore the line of code?

Thank you anyway for your help.
irsah replied on at Permalink Reply
irsah
If i can recall. i used the the image !isset method to call a default image when there is no image to a page (edit or not).
GBNT replied on at Permalink Reply
GBNT
How do I do that?
I'm a designer, not a programmer. I can hack my way through HTML and CSS easily but not so much with PHP...
Could you expand a little more please?
irsah replied on at Permalink Reply
irsah
Hey GBNT me too, i had to dug around, but here is a thread which recently explains the default image methodhttp://www.concrete5.org/community/forums/customizing_c5/issue-with... thanks to Netjunky.

Keep in mind it grabs the thumbnail images and not the relative path image. Quality does differs.

p/s: it's in the middle of the thread.
irsah replied on at Permalink Best Answer Reply
irsah
Hey GBNT, you can correct me if i wrote it wrong here..
<?php if($c->getAttribute('image_attribute')) { ?>
<img src="<?php echo ($c->getAttribute('image_attribute')->getVersion()->getRelativePath());?>">
<?php } ?>


You can also add in a default image using the thread i linked before but thinking it's only for your page default mode, scratch that again.

irsah.
GBNT replied on at Permalink Reply
GBNT
Thank you!

That did the trick perfectly. :)

Cheers
irsah replied on at Permalink Reply
irsah
You're welcome mate.. good day.