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.

General Questions

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

Accessing image attributes for scaled image


3 Posts   496 Views

Bruce B

27 February 2012 at 7:37pm Community Member, 145 Posts

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?


1 March 2012 at 4:55pm Community Member, 35 Posts

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


Bruce B

6 March 2012 at 7:56pm Community Member, 145 Posts

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.