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.

General Questions /

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

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

Accessing image attributes for scaled image


Go to End


3 Posts   1288 Views

Avatar
Bruce B

Community Member, 164 Posts

27 February 2012 at 7:37pm

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?

Avatar
Chris_Bryer

Community Member, 35 Posts

1 March 2012 at 4:55pm

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

Avatar
Bruce B

Community Member, 164 Posts

6 March 2012 at 7:56pm

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.