17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1409 Views |
-
Alt text on images

22 October 2008 at 8:41pm Last edited: 22 October 2008 8:43pm
Hi,
I am using resized images in a couple of templates, and was wondering how to set the alt attribute on those.
I've extended the Page class with
static $has_one = array(
'Photo' => 'Image',
);and I call the image in the template with:
<% if Photo %>
$Photo.SetWidth(130)
<% end_if %>And thats all fine. But say I would like to use the image title (set in Files & Images) as the alt text for the image - How do I do that?
-
Re: Alt text on images

22 October 2008 at 8:58pm
Hey superautomatic,
You should be able to do something like this:
<% if Photo %>
<% control Photo.SetWidth(130) %>
<img src="$URL" alt="$Title"/>
<% end_control %>
<% end_if %> -
Re: Alt text on images

22 October 2008 at 9:18pm
Thanks a lot for a quick response!
Your suggestion seems to work fine, except that $Title doesn't seem to be the name of the variable holding the image title (the alt field in the generated html is still blank).
So, anyone knows the name of the image title variable? (or where to find it in the documantation...)
/Jens
| 1409 Views | ||
|
Page:
1
|
Go to Top |


