Archived topic
WP Show Posts support for img src set
13 replies · Started by Matt on May 8, 2020
Hey,
Loving working with GP so far and using the Dispatch theme. It relies heavily on the WP Show Posts plugin, but a drawback is that this plugin doesn't use the srcset property for images, so all images are being served at full size - even if they are being resized by the CSS.
I appreciate you're working on the changing it for Gutenberg at the moment but would like to suggest implementing this as a priority.
I'd imagine quite a few others heavily weighed up the impact of speed when buying this theme - as I did. This currently impacts my site a fair bit and having images served at different size based on display size would be a massive help.
Hi Matt,
As long as you don't use the WPSP image width/height controls, they should use srcset like anything else.
Can you check with those options empty?
Let me know :)
Hey, I think this is to do with a cdn I have - thanks for the response though!
No problem!
Hello,
I am also using this plugin, is it possible to implement src set even when using WPSP image width/height controls?
I need to use these controls in my article listings...
Thanks
Regards
Hi there,
unfortunately not - if you change the sizes then it overwrites the srcset sizes.
You can of course add more media attachment sizes to the srcset:
https://docs.generatepress.com/article/adding-image-sizes/
This would allow you to add sizes that are more conducive to your different responsive layouts.
Thank you David, I see in the tutorial how to add new image sizes to my Wordpress site, but it is not clear to me how to add the media attachment sizes to the srcset in the article lists I create with WPSP plugin.
I believe currently you can only set the Default size for ALL WPSP Images using this filter:
add_filter( 'wpsp_default_image_size', function() {
return 'your-size-name';
} );
You cannot currently set them differently for each list. Tom has it planned in for WPSP 1.2.
However, how are you lists displayed on responsive views? ie. fewer columns with larger images on Tablet and Mobile. If thats the case then you probably want to leave src-set to do its thing and just create additional attachment sizes if required to fill that need.
Hi David,
I'm not sure I understand.
In my case I would have, for example, a list with the following dimensions:
2 columns with 640x360 images
in the mobile version the images should become 423x238
I hope I have better clarified my need.
Thanks
Regards
Lorenzo
On load the browser will calculate the size of the image container, and with those dimensions selects the nearest image size available.
You can therefore register images attachment sizes that are more appropriate for your site.
Eg. A medium size of 440px to suit your mobile columns.
So are you suggesting me not to set the image size with the WP Show Posts Controls? In this way it will use the native Wordpress src set?
If I understand correctly, it would be enough for me to create sizes that suits my needs with Regenerate Thumbnail plugin, correct?
Yes, thats correct :)
In this way the problem I have is that all images in archives have different heights, so the archive page becomes ugly to see... maybe the best solution for me is to wait for the WPSP 1.2 release, so I can set the defalut size image for each list. Do you already know when the next release will come out?
When using the add image size you can just define the width, this will 'auto' the height and keep the original aspect ratio eg.:
add_image_size( 'my-custom-image-name', 440 );
WPSP Pro version 1.0 is still in alpha and this is next on our list of updates.
We don't have a definitive time line on 1.2 release just yet.