Progressive Images blog title single.html

Hello.
I’ve successfully implemented a shortcode to .Resize *.webp images (an update to the Laura Kalbag method). I had to implement Leaf Bundles with resourses: in my yaml frontmatter.

This takes care of all the images within the blog post (which is output on /layouts/single.html.

However, I’m trying to get the main image to be processed the same way, and I believe that the template single.html cannot use shortcodes.

I’ve asked Aunt Google to no avail. Any pointers on where to search for some help? The main issue I’m having is that I’m having difficulty getting the Width of the image.

The furthest I’ve gotten without any errors is

{{ if .Params.image }}
  <picture>
  {{ $Img := .Params.image }}

I have about a years worth of weekly blog posts, but I just started using Leaf Bundles. Not sure if that would help (although it would be great to find a backwards compatible menthod).

Again, any pointers appreciated.

will try to help …

You need to load the image resource

{{ $image := .Page.Resources.GetMatch (printf "%s" $Img) }}

see doc for GetMatch!

the you can use it

{{ with $image }}{{ $iw := .Width }}{{ $ih := .Height }} ... {{end}}

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