A quick tutorial on how I do on-demand image resizing with Bridgetown
Oh this is a really cool approach! This has so much potential!!
Lets start with what I love:
The idea of “hashing” the resized images is so smart so we don’t need to recalculate and generate images on every build. Super cool!
+1 for Vips + Image Processing. Coming from Rails, those feel very natural.
The unexpected: I assumed “on demand image resizing” meant having multiple sizes, rather than only a single resize of an image.
I’m also not particularly in love with is adding the ERB helpers, I’d be quite interesting in using a post-build
inspector
to generate the image hashes and using thesrcset
attribute on<img>
to utilize that which HTML already gives us, and have truly “dynamic” image sizes across device / viewport sizes! The added benefit being you can have multiple sizes, instead of a single resized image.In my head, I picture doing something like this:
<img src="blah.jpg" data-sizes="thumbnail, 640x640, wallpaper">
or something silly like that.Anyways, thank you so much for this post! So much to build off of here!
This is awesome! 🤘 I’m excited to play around with your approach.