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.

Template Questions /

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

Add Image to Template with an ID


Go to End


3 Posts   2256 Views

Avatar
spierala

Community Member, 80 Posts

24 November 2009 at 6:51am

hello all,

i´m successfully adding an Image to my template using

<% control myStartImage %>
      $Image
<% end_control %>

I would like to give that image an ID for replacing it with the help of jquery. Is this possible?

many thanks for your help,
florian

Avatar
Double-A-Ron

Community Member, 607 Posts

25 November 2009 at 4:29pm

Edited: 25/11/2009 4:31pm

<% control myStartImage %>
    <img src="$URL" id="image_{$ID}" />
 <% end_control %>

The id can be whatever you like of course. I just used a string with the $ID value as I knew it would definitely be there. The curly braces will seperate any string suffix or prefix from the template variable.

Aaron

Avatar
spierala

Community Member, 80 Posts

30 November 2009 at 10:09pm

Hey Aaron!

Thanks! I see there are serveral ways to include an image! Works great that way!

Greetz,
Florian