Image Attributes

Permalink
I'm assuming there's a way to add an image attribute to regular pages so users can simply attach and re-size an image that gets embedded automatically into the content of a page?

Are there any instructions on how to do this? I've been able to do it with thumnbnails on news stories.. but I'm not sure how to do it with a medium sized image on a page.

getjoel
View Replies:
jordanlev replied on at Permalink Reply
jordanlev
Here is how to do it for background images, but it's the same thing (just insert the attribute image into an <img> tag in your html instead of a background-image):

http://www.concrete5.org/community/forums/customizing_c5/themes-and...
http://www.concrete5.org/community/forums/customizing_c5/background...
http://www.concrete5.org/community/forums/themes/customising-theme-...
getjoel replied on at Permalink Reply
getjoel
I tried putting this <img src="<?php echo $img_src; ?>" align="right" width="480">
in front of my primary and then attaching an image via the attribute.. but nothing happened.. This is what it looked like ..

<img src="<?php echo $img_src; ?>" align="right" width="480">
<?php
$a = new Area('Primary');
$a->display($c);
?>

What do I do wrong?
jordanlev replied on at Permalink Reply
jordanlev
Need to see the other code that's in that file -- I have no idea what's going into $img_src otherwise. Can you post your entire template file?
getjoel replied on at Permalink Reply
getjoel
Sure.. I had taken the code in the link above and replace background with image.. I was probably not doing it correctly.. but this is the entire page..

<?php $this->inc('elements/header.php'); ?>
<?php
$a = new Area('Breadcrumb Nav');
$a->display($c);
?>
<div id="primary" class="content">


<div id="sidebar_left">
<?php
$a = new Area('Sidebar');
$a->display($c);
?>

</div>
<div id="main_left">
<img src="<?php echo $img_src; ?>" align="right" width="480">


<?php
$a = new Area('Primary');
$a->display($c);
?>


</div>


</div>


<?php $this->inc('elements/footer.php'); ?>
jordanlev replied on at Permalink Reply
jordanlev
The problem is you just pulled out one line of code without all of the other supporting code that actually makes it work. I think what you want is this:
<img src="<?php echo $c->getAttribute('your_attribute_handle')->getRelativePath(); ?>" width="480" height="320" alt="" />

Note that you will need to change "your_attribute_handle" to whatever the handle of your image attribute is. Also change the width and height accordingly.
Also note that this is the most basic way to do this possible -- if you want thumbnailing instead there's some more complex code you can use, but this should get you most of the way there.
getjoel replied on at Permalink Reply
getjoel
Thank you.. That worked perfectly. The only problem is if I don't attach an email the page shows up with just the left column and that's it..

http://www.getcontrolfreak.com/websites/precision/index.php?cID=135...

This is the code I used for the page..

<?php $this->inc('elements/header.php'); ?>
<?php
$a = new Area('Breadcrumb Nav');
$a->display($c);
?>
<div id="primary" class="content">


<div id="sidebar_left">
<?php
$a = new Area('Sidebar');
$a->display($c);
?>

</div>
<div id="main_left">
<img src="<?php echo $c->getAttribute('image')->getRelativePath(); ?>" width="480" height="320" alt="" align="right">


<?php
$a = new Area('Primary');
$a->display($c);
?>

</div>

</div>

<?php $this->inc('elements/footer.php'); ?>