Archived topic
Wrong sized image file used on mobile
6 replies · Started by Forum User on November 15, 2019
Hi! A GP Pro member here with a bug report for WP Show Posts. I hope it's ok.
I was over the moon a month ago when I finally figured out how to use smaller image files with WP Show Posts. I used the following solution provided by Tom: https://generatepress.com/forums/topic/image-sizing-not-working-with-amazon-web-services-and-wp-offload-media/.
The code I use is:
add_filter( 'wpsp_default_image_size', function() {
return 'medium';
} );
Now I noticed that the filter works only for desktop. When the page is loaded on mobile or tablet, full sized images are loaded.
I noticed this first in Firefox Inspector and can see the same if I run webpagetest.org with both desktop and mobile emulation.
Thanks,
-Rauno.
Hi there,
Is there a WPSP list on the page you linked us to? I'm not seeing it.
Let me know :)
Hi Tom,
There are two WPSP lists on the page: One between tutorial steps 4 and 5. And another one between steps 8 and 9.
Thanks!
Ah, well the code is working, but srcset is in use, which provides different image sizes for different screen sizes. It's possible to remove it if you'd like?
Thanks Tom. I had to spend a couple of hours reading about srcset and sizes attributes and related WordPress functionality.
I ended up disabling the WordPress default srcset attributes. I used these snippets: https://perishablepress.com/disable-wordpress-responsive-images/. Everything seems to be working fine and loaded images have much smaller file size now.
In the long run, though, I would be more comfortable if WP Show Posts would specify "optimal" sizes attribute. Do you think that would be possible?
Thanks!
-Rauno.
The entire image resizing option in WPSP (and GP) needs to be re-done. It's high on my priorities :)
👍 Thanks!