- This topic has 8 replies, 2 voices, and was last updated 4 years, 1 month ago by
David.
-
AuthorPosts
-
August 18, 2021 at 2:18 pm #1900649
a1reno
Hi,
I was speaking to a plugin author about my pagespeed insights results and he said that my featured image on mobile looks like it is requesting a 1000×667 image in the space for that image, when the space is only 337×225.’
1000×667 is the original size of the featured image when I uploaded it. Does this mean that I have lost some of my thumbnails sizes that should have been generated when the initial image was uploaded? Or is there some setting in Generatepress that I may have changed accidentally?
I do remember a few weeks back messing about restoring my original image compression and trying to regenerate the thumbanils again. Perhaps they didn’t regenerate properly?
August 18, 2021 at 3:55 pm #1900691David
StaffCustomer SupportHi there,
all your image sizes are still in the src-set. The browser can select the best sized image for its purpose, screen size, resolution etc. However one of the factors in the browser making this decision is the
sizes
attribute in the image.By default WordPress uses this:
sizes="(max-width: 750px) 100vw, 750px
Which without explaining the goobledigook is the 750px width image will be used IF the image fills the viewport of the screen. As your images have padding round them, they don’t fill the viewport width. Which leaves the browser to choose what size it thinks is best. Which can result in it choosing the largest size.
There are some things we can do to change that behaviour. The simplest one for you would be to set the max_width loaded in the src-set using this PHP Snippet:
function set_max_srcset_width( $max_width ) { $max_width = 750; return $max_width; } add_filter( 'max_srcset_image_width', 'set_max_srcset_width' );
August 18, 2021 at 7:13 pm #1900777a1reno
Hi,
Before I try adding the PHP. Would it be simpler if I moved the padding around the featured image?
I tried to do this using the customizer toggle and it now appears I have some padding to the right of the image. Do you know what this is or where it comes from? Could this be causing the issues?
August 18, 2021 at 11:13 pm #1900910a1reno
I’ve worked out that the space is the right sidebar showing up which I was hoping would only show up on desktop but seems to be the reason for that space.
So how would I set things back to normal so that I can avoid using that PHP script if possible and make sure browsers are picking up the correctly sized images?
August 19, 2021 at 4:27 am #1901142David
StaffCustomer SupportCan you disable the padding around the image so i can see what the issue is ?
August 19, 2021 at 4:33 am #1901149a1reno
Hi David,
I’ve disabled the padding.
August 19, 2021 at 5:55 am #1901209David
StaffCustomer SupportThats weird…. try adding this CSS to fix that:
@media(max-width: 768px) { .one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image { margin-right: -30px !important; } }
August 19, 2021 at 6:02 am #1901216a1reno
Hi David,
Before I add that code you supplied, I see that Mediavine added some code a while back (I can’t remember what it’s for!).
Would this have anything to do with it the issue?
I’ve deleted the bottom one as a test and I don’t see any difference to my site so I am wondering if i can delete it.
August 19, 2021 at 6:17 am #1901229David
StaffCustomer SupportYeah you can delete the bottom one.
-
AuthorPosts
- You must be logged in to reply to this topic.