- This topic has 6 replies, 2 voices, and was last updated 4 years, 8 months ago by
David.
-
AuthorPosts
-
July 14, 2021 at 4:57 pm #1856099
George
I have the three default image sizes set in the Media settings as the following:
Thumbnail size: 150 X150
Medium size: 450 X 300
Large size: 1000 X 667In addition, I’ve added an extra dimension that I would like to have for my featured image archives:
add_action( 'init', function() { add_image_size( 'archive_featured-image', 387, 258, false ); } );387px is the size that I’ve calculated the featured image to be for the archives on desktop, similar for other devices.
I have also set up a block content template element type to display on my archives and have set the image size to be
archive_featured-image.What I would expect to see when visiting the archive is for the correct SCRSET to be selected which it doesn’t. As far as I understand, setting
archive_featured-imagefor the featured image in the content template block element will select that scrset size or smaller:
https://generatepress.com/forums/topic/how-do-i-load-srcset-featured-image-for-mobile-and-desktop/#post-1661600Instead, I am getting a size of 768X512px and I have no idea where that size is coming from. In sizes less than 294px device-width, I get the 450X300px size image. And in size less than 209px device-width, I get the 387X258px size image. I can see those images served from the Network tab in the Chrome inspector.
Of course, I have regenerated all thumbnails.
Can you help clear the confusion?
July 15, 2021 at 5:53 am #1856630David
StaffCustomer SupportHi George,
the 768x size image is the
medium_largeattachment size that WP generates.
The browser selects from src-set sizes the best fit image for the purpose which considers the screens pixel density.
See here when i set the DPR of the device to1it grabs the smallest image:July 15, 2021 at 10:22 am #1857130George
I thought, setting an image size in the post template would take that size or anything smaller as described in the post that I attached earlier in which you comment. Is that not the case?
July 21, 2021 at 5:23 am #1864421George
Hi David, Is there any news on this? Should I assume that the size set in the dynamic image is not being taken into consideration?
July 21, 2021 at 5:29 am #1864430David
StaffCustomer SupportHi George – sorry i though i replied to your previous reply, my loggin must have expired on submit.
Thats correct, unless we force the maxsizes option for it then WP will load the larger sizes. Its something we’re looking at.July 21, 2021 at 9:45 am #1865024George
Ok, yes, I see. It actually grabs the width and height attributes of what’s set for the image but displays the higher SCRSET one! I think for the time being I will restrict max SCRSET width as you explain here.
July 21, 2021 at 9:53 am #1865035David
StaffCustomer SupportYep – thats the function 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.