Open WYF99 opened 3 months ago
I was struggling with the same thing, so I dug into it. I think this is not technically a bug, but instead the interaction of non-obvious expected behavior from two different plugins:
jekyll-imagemagick
only scales images down (not up)medium-zoom
calculates the zoomed size based on what's in sizes
, not the source image's actual dimensionsjekyll-imagemagick
only scales images down (not up)cmd += "-resize \"#{long_edge}>\" #{resize_flags} "
You can also see this by examining what jekyll-imagemagick prints to the Jekyll logs, which looks like:
> Imagemagick: Running command "convert "/path/to/assets/img/1.jpg" -quality 85 -resize "1400>" "/path/to/_site/assets/img/1-1400.webp""
The `>` in the geometry "shrinks an image with dimension(s) larger than the corresponding width and/or height argument(s)" ([source](https://legacy.imagemagick.org/script/command-line-processing.php#geometry)).
…but the TL;DR is: images that start out with a width smaller than what's requested in site.imagemagick.widths
will be output without any resizing, no matter what their file names claim.
If you inspect the responsive images created by jekyll-imagemagick
for the example site content, images that are supposed to be 1400px wide are still 800px wide, since the originals are all 800px wide. This means the default srcset
is also mis-specified, since width descriptors are supposed to match the actual image widths.
Most immediately, perhaps the documentation of this feature in al-folio and the example content could clarify for users what to expect? Namely:
site.imagemagick.widths
should be smaller than your smallest image width, otherwise you will be needlessly generating (and incorrectly plugging into srcset
) duplicate images with unchanged size.People who are up for customizing might want to look into the other responsive image plugins out there, some of which offer more flexibility.
So for @WYF99, the upper limit on the zoomed thumbnail size will be 480px wide, even though there are images in the srcset
that claim to be 800px and 1400px (they aren't – they're all 480px, too). But that doesn't solve the tiny zoom problem, since the zoomed previews often aren't even making it to 480px wide. That's because…
medium-zoom
calculates the zoomed size based on what's in sizes
, not the source image's actual dimensionsOn @WYF99 's page, the thumbnails have been given sizes="200px"
. The thumbnails actually render at 70px–125px width (depending on viewport size) for the larger Bootstrap breakpoints.
Taking the viewport >1200px case as an example, the concrete size of the thumbnails is 125px wide, while the physical width of the source image is 480px. But instead of the zoom scaling factor being calculated as 480 / 125
, it's being calculated as 200 / 125
, resulting in a too-small zoomed image.
sizes
specification (but this is non-trivial and maybe even sub-optimal).Use medium-zoom
's data-zoom-src
attribute to explicitly point to a larger image to use for the zoomed view. You can specify it like:
<img src="/assets/img/1.jpg"
srcset="/assets/img/1-480.webp 480w,
/assets/img/1-800.webp 800w"
sizes="95vw"
data-zoomable
data-zoom-src="/assets/img/1-800.webp">
I think this could be incorporated into figure.liquid
, perhaps even with some logic for picking which image size you want assigned as the zoomed source.
The second approach is probably easier, since highly granular sizes
specs get really verbose and painful to generate, and what you need to get desirable zoom scales might trade off against what you need to optimize page loading speed. Also, you'd still be leaving the browser in charge of picking exactly which size image is used for the zoomed view, which can result in visibly inconsistent behavior.
Have you checked that your issue isn't already filed?
Bug description
Publication preview thumbnails are not enlarged and displayed at original size upon mouse click
How to reproduce the bug
Error messages and logs
No error message.
What operating system are you using?
Not applicable (e.g. you're using GitHub Pages or other hosting)
Where are you seeing the problem on?
Deployed site
More info
A publication thumbnail is displayed at a reduced size by default, which is supposed to be centered, enlarged, and displayed at its original size upon click. In reality, the thumbnail is simply centered without any size change.
According to @george-gca from #2662