Jump to:

22976 Posts in 11702 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Accessing image attributes for scaled image

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: 433 Views
  • Bruce B
    Avatar
    Community Member
    145 Posts

    Accessing image attributes for scaled image Link to this post

    I am working with a new module - Display Anything - to create an image gallery. It returns an array of images that can be used to create the gallery. I can work with the full sized images using their attributes: $URL $Height etc. I can also display resized images e.g. $PaddedImage(80, 80).

    What I need to do, and cannot, is retrieve the attributes such as $URL and $Height from a resized image.

    In other instances, I have just sub-classed Image to create my own functions. That doesn't seem to be an option here.

    Any suggestions?

  • Chris_Bryer
    Avatar
    Community Member
    35 Posts

    Re: Accessing image attributes for scaled image Link to this post

    going from memory here, its going to be something like:

    <% control MyImage %>
    <% control PaddedImage(80 80) %>
    <img src="$Link" height="$Height" alt="$Title" />
    <% end_control %>
    <% end_control %>

    I cant remember if PaddedImage has a space or comma between the parameters in the control block, but its something like this..

    -Chris

  • Bruce B
    Avatar
    Community Member
    145 Posts

    Re: Accessing image attributes for scaled image Link to this post

    Chris,
    Thanks for that. Unfortunately PaddedImage doesn't return an object, just an img tag string. I have rejigged my code so i don't need to access the attributes. The alternative would be to use javascript to extract the information from the tag.

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