Jump to:

23493 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » getting more control (or less?) over images

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 482 Views
  • lozhowlett
    Avatar
    Community Member
    146 Posts

    getting more control (or less?) over images Link to this post

    Guys

    I want to output an image with an onmouseover effect (changing a large image for the one selected onmouseover from a list of thumbs).

    <% control Resources %>
    <% control Attachment %>
    $CroppedImage(81,80)
    <% end_control %>
    <% end_control %>

    how do I get into do something like...

    <% control Resources %>
    <% control Attachment %>
    <img src ="$attachment.url" onmousemove="somejavaScriptfnc()">
    <% end_control %>
    <% end_control %>

    as this just produces img src = "".

    Thanks!

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: getting more control (or less?) over images Link to this post

    If you're in the Attachment loop then skip the prefix.
    It should just be

    <img src="$URL" onmousemove="somejavaScriptfnc()">

  • Phill
    Avatar
    Community Member
    75 Posts

    Re: getting more control (or less?) over images Link to this post

    I think you want to do something like this

    <% control Resources %>
    <% control Attachment %>
    <img src ="<% control SetRatioSize(81,80) %>$URL<% end_control %>" onmousemove="somejavaScriptfnc()">
    <% end_control %>
    <% end_control %>

  • lozhowlett
    Avatar
    Community Member
    146 Posts

    Re: getting more control (or less?) over images Link to this post

    cool - thanks guys, both works, just personal preference how I end up doing it in the template. cheers!

  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Re: getting more control (or less?) over images Link to this post

    PROTIP: You can save yourself some lines of code by shortening the block to:

    <% control Resources %>
    <img src ="<% control Attachment.SetRatioSize(81,80) %>$URL<% end_control %>" onmousemove="somejavaScriptfnc()">
    <% end_control %>

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: getting more control (or less?) over images Link to this post

    I wouldn't over use the dot notation because the template will fail if not present, the control tag would not.
    Also the dot notation cannot be chained nore than once (i think, so something.this is ok, but some.thing.else isn't ok).

    482 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.