Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Add Image to Template with an ID

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

Page: 1
Go to End
Author Topic: 1428 Views
  • spierala
    Avatar
    Community Member
    80 Posts

    Add Image to Template with an ID Link to this post

    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

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: Add Image to Template with an ID Link to this post

    <% 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

  • spierala
    Avatar
    Community Member
    80 Posts

    Re: Add Image to Template with an ID Link to this post

    Hey Aaron!

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

    Greetz,
    Florian

    1428 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.