Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

add ID to ImageField


Go to End


3 Posts   1921 Views

Avatar
Daimz

Community Member, 36 Posts

2 August 2009 at 10:52pm

How do I add a ID to and image feild?

Avatar
joshy

Community Member, 57 Posts

4 August 2009 at 10:01am

What do you mean? For what purpose?

http://doc.silverstripe.org/doku.php?id=imagefield will tell you about how to create an image field. If, however, you mean on a model level (which you may consider 'database' level), then all fields have IDs. So:

$has_one = array('Photo' => 'Image');

Will link an image to the page you're on (calling it Photo). Photo's ID can then be called with $this->PhotoID from within the page it's used.

Avatar
Daimz

Community Member, 36 Posts

4 August 2009 at 11:50pm

I mean an ID that I can style.
I will be adding lots of images over time and I want to give them a specific ID tage which will allow me to style with css.