Get image size from .Page.Resource

I was thinking about building a shortcode that would produce a gallery from the indication of a folder. Something like this:

 {{ $galleryimages := .Page.Resources.Match "gallery-*" }}
 {{ range $galleryimages }}
 {{ $thumbnail := .Resize "320x" }}
 		<figure itemscope itemtype="" class="image">
 		  <a href="{{ .Permalink }}" itemprop="contentUrl" data-size="--SIZE--" >
 		      <img src="{{ $thumbnail.Permalink }}" itemprop="thumbnail" alt="--caption--" />
 		  <figcaption itemprop="caption description">
 		    <span itemprop="copyrightHolder">--copyrightHolder--</span>
 {{ end }}

The only missing piece, is to be able to get the width and height of the image for the data-size attribute.

Is there a way to get this directly from the file?

Nevermind, found the answer :slight_smile:

<a href="{{ .Permalink }}" itemprop="contentUrl" data-size="{{ .Width }}x{{ .Height }}" >

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.