Archived topic
Image sizes displayed by Search.php - data-srcset and data-sizes
1 reply · Started by Simon on July 8, 2020
Hi Tom, David, Leo
I have created a grid layout for the archive, category archive and search pages on this website, using CSS. The image sizes are usually selected correctly from the srcset. - However, on the search results pages the full size 1280px images are selected, even though the page should deliver the small 267px or 535px thumbnails.
Inspecting the code shows the data-sizes instruction to be the problem:
data-sizes="(max-width: 1206px) 100vw, 1206px"
I can't work out where this is coming from. By contrast, the main archive shows:
data-sizes="(max-width: 201px) 100vw, 201px"
for portrait photos, and
data-sizes="(max-width: 268px) 100vw, 268px"
for landscape photos.
Can you see where this 1206px instruction on the search results page is coming from? and/or how I change it?
(In case it's relevant - I created a copy of search.php in the child theme, in order to place the search results within a <div>, as a means to use CSS to present those results within the same grid layout as the main archive, while leaving the heading outside the grid. I have mirrored the same container sizes in the archive and search page (only with a slight adjustment for screens over 1000px) - and those containers work correctly.)
Hope you can see the problem. Thank you!
Hi there,
I'm seeing max-width: 960px right now.
I'm not sure what would cause such a big difference - WordPress does all of that calculation.
Does it still happen with your other plugins deactivated?