Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » SOLVED: Getting Filename of a resized image in view

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

Page: 1
Go to End
Author Topic: 557 Views
  • Silverfish
    Avatar
    Community Member
    59 Posts

    SOLVED: Getting Filename of a resized image in view Link to this post

    Hi All,

    I'm looking for a way to geht just the path to an resized image in a template, i.e.

    <div style="background:url($Img.SetWidth(100).Filename)"></div>

    unfortunately when I'm writing it this way, I get

    <div style="background:url(<img src="/path/to/image.jpg" alt="image" />.Filename)"></div>

    Is it possible to get the filename without writing an extra method to the model?

    Thanks for any hint!

    Regards
    SF

  • rob.s
    Avatar
    Community Member
    78 Posts

    Re: SOLVED: Getting Filename of a resized image in view Link to this post

    Hi Silverfish,

    try

    <div style="background-image: url(<% control Image.SetWidth(100) %>$URL<% end_control %>)"></div>

    or

    <div style="background-image: url(<% control Image %><% control SetWidth(100) %>$URL<% end_control %><% end_control %>)"></div>

  • Silverfish
    Avatar
    Community Member
    59 Posts

    Re: SOLVED: Getting Filename of a resized image in view Link to this post

    Hi Rob,

    The first one did the job, thanks a lot!

    SF

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