Image dimensions in templates?

Kyle Fox's Avatar

Kyle Fox

25 Jun, 2011 05:11 PM via web

is there a way to get the width & height of an image within a template?

I'm allowing my client to create ads, and would like to do something like this:

<a href="{{ item.data.ad_url }}" style="background-image: url({{ item.data.ad_image.url }}); width: {{ item.data.ad_image.width }}; height: {{ item.data.ad_image.height }};">
    {{ item.data.ad_alt_text }}
</a>

I realize this might not be possible at the moment, but it would be quite handy.

  1. 2 Posted by John Nunemaker on 25 Jun, 2011 05:17 PM

    John Nunemaker's Avatar

    If you piped the background image url through an image size you would always know the width and height. Are you expecting one ad to be a different size than another?

    http://docs.harmonyapp.com/harmony-templates/filters/text-filters/#...

  2. 3 Posted by Kyle Fox on 25 Jun, 2011 05:21 PM

    Kyle Fox's Avatar

    Thanks, I think that filter will work. Somehow missed it in the docs.

  3. Kyle Fox closed this discussion on 25 Jun, 2011 05:21 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

17 May, 2012 10:45 PM
20 Mar, 2012 05:05 PM
26 Apr, 2012 01:40 AM
07 Mar, 2012 04:42 PM