17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1476 Views |
-
Images, Templates and alt attributes

16 January 2008 at 3:55am
Hello,
I need the alt attribute of my image to be the title of the page it is being viewed on. any ideas?class StaffPage extends Page{
.....
static $has_one = array(
'Photo' => 'Image'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo'));
return $fields;
}
} -
Re: Images, Templates and alt attributes

16 January 2008 at 4:26am
Check out the Image API http://api.silverstripe.com/default/Image.html#URL
There are a lot of different methods that you can use but I think this should be a good solution:<img src="$Photo.getFullPath" alt="$Title"/>
| 1476 Views | ||
|
Page:
1
|
Go to Top |


