Image Attribute

Permalink
Not sure what I'm missing here.. but I'm simply trying to set up an image attribute on the page.. I've added to <img src="<?php echo $c->getAttribute('image')->getRelativePath(); ?>" width="480" height="320" alt="" align="right"> to the left of my primary container.. and now no content on the page at all shows up unless there's an image attribute applied.. Please help.

getjoel
 
jshannon replied on at Permalink Reply
jshannon
Hi.

When something like this happens you should look in the source.

You'll most probably see something like
<img src="some error, probably a lot of text, and including a quote mark" width="....


That should give you a sense of what's wrong.

But I just tested the code, and it works fine, so my first guess is that image isn't the attribute name, or that the attribute hasn't been set for that particular page.

Unless you can guarantee that attribute will be set on all pages that you have that code on, you'd want to do something like:

<?php if ($file = $c->getAttribute('image')) { ?>
  <img src="<?php echo .... ?>" ... 
<?php } ?>


James
C5LABS replied on at Permalink Reply
C5LABS
Hi Getjoel
Take a look at this, might solve your problem.
http://www.concrete5.org/community/forums/customizing_c5/custom-att...