-
AuthorPosts
-
October 22, 2024 at 7:09 pm #1469638
If I load this page, it displays properly on a PC and via Dev Tools. If however I view the page on an Android phone, the thumbnail of the Hotel Nevada near the bottom of the page is not shown – https://imgur.com/l350MY4.
The img code is:
<img loading="lazy" decoding="async" aria-describedby="caption-attachment-7644" class="size-square wp-image-7644" src="https://www.americanroadtrips.net/wp-content/uploads/2019/11/Hotel-Nevada-180x101.jpg" alt="Hotel Nevada at night" width="180" height="101" srcset="https://www.americanroadtrips.net/wp-content/uploads/2019/11/Hotel-Nevada-180x101.jpg 180w, https://www.americanroadtrips.net/wp-content/uploads/2019/11/Hotel-Nevada-300x169.jpg 300w, https://www.americanroadtrips.net/wp-content/uploads/2019/11/Hotel-Nevada-80x45.jpg 80w, https://www.americanroadtrips.net/wp-content/uploads/2019/11/Hotel-Nevada-495x279.jpg 495w, https://www.americanroadtrips.net/wp-content/uploads/2019/11/Hotel-Nevada-150x84.jpg 150w, https://www.americanroadtrips.net/wp-content/uploads/2019/11/Hotel-Nevada.jpg 700w" sizes="(max-width: 180px) 100vw, 180px">
The image is inserted on the page as the 180×101 px size thumbnail, with a lightbox link to the full size media file. I use the Simple Image Sizes plugin and also remove multiple Enfold images from being created in functions.php
However when the original image was first uploaded a Portfolio size image was created of 495×279 px. As you can see, this is referenced in the img code. Since then, to save space I have deleted all unnecessary thumbnails. Thus Hotel-Nevada-495×279.jpg no longer exists in Uploads.
I then edited the page, deleting the image, saving and updating. I did this to remove the reference to the 495px image from srcset. I then added the photo back onto the page and updated.
The code on the page, despite me deleting the photo and then re-adding it, is still referencing the 495 px image, per the code block above (and you can verify this on the live page).
The reason on Android no image is shown is because there is no 495 px file. But I know Enfold is trying to load this file because I created a file called Hotel-Nevada-495×279.jpg from the 180 px size image then uploaded it, refreshed the page on my Android phone – and the ‘false’ thumbnail was then seen. I’ve since deleted this.
1. Primary issue – why is Enfold even trying to load a 495 px wide image in responsive mode and not the 180 px image specified on the page?
2. After deleting the image from the page then re-adding it, why is Enfold still adding a reference to srcset to an image size that does not exist?
3. I have regenerated the thumbnails for the image and a 495 px size is not being created – the image stats then says “5 images reduced by 114.3 KB (66.4%)” yet View Stats lists 6 thumbnails, including a Portfolio at 495 px wide, even though the file does not exist. The image’s Attachment Metadata has a reference to ‘portfolio’ – is this the problem and if so why does regenerating the thumbnails not remove this given the Portfolio size is no longer allowed?
October 23, 2024 at 7:22 am #1469662Hey zimbo,
Thank you for the inquiry.
What happens when you remove the srcset and sizes attribute from the image? The size 180×101px should be good enough for desktop and mobile view.
<img loading="lazy" decoding="async" aria-describedby="caption-attachment-7644" class="size-square wp-image-7644" src="https://www.americanroadtrips.net/wp-content/uploads/2019/11/Hotel-Nevada-180x101.jpg" alt="Hotel Nevada at night" width="180" height="101">
Best regards,
IsmaelOctober 23, 2024 at 1:49 pm #1469690In debug mode, the page has this:
[caption id="attachment_7644" align="alignright" width="180"]<a href="https://www.americanroadtrips.net/wp-content/uploads/2019/11/Hotel-Nevada.jpg"><img class="size-square wp-image-7644" src="https://www.americanroadtrips.net/wp-content/uploads/2019/11/Hotel-Nevada-180x101.jpg" alt="Hotel Nevada at night" width="180" height="101" /></a> Hotel Nevada at night[/caption]
…but this gets translated on the live page to the img code with srcset and sizes that I posted above.
What happens when you remove the srcset and sizes attribute from the image?
How do I do that?
October 24, 2024 at 4:55 am #1469719Hi,
Thank you for the update.
…but this gets translated on the live page to the img code with srcset and sizes that I posted above.
Have you tried using a different size of the image instead? Please provide the login details in the private field so that we can check the issue further.
Best regards,
IsmaelOctober 24, 2024 at 9:56 am #1469747October 24, 2024 at 1:19 pm #1469764Details in private.
October 25, 2024 at 5:59 am #1469809Hi,
Did you change the login URL? We can’t access the login or admin page using the default login URL. Please provide the custom URL in the private field.
Best regards,
IsmaelOctober 25, 2024 at 2:00 pm #1469836Sorry, forgot about that…
October 27, 2024 at 3:09 pm #1469939October 28, 2024 at 5:21 pm #1470028Still doesn’t show the image after clearing phone cache. Have re-loaded the page multiple times.
I turned on Remote Debug for Android devices and inspected the page via Dev Tools – https://imgur.com/gallery/debug-dQTFKAs.
As you can see the phone is still trying to load the 495×279.jpg file, which no longer exists.A similar problem existed on the next day’s page. Android was trying to load the 495px images of the top two photos. So, I re-uploaded both of those photos and edited the page to load these new images.
The original image is FULL. As 495px is no longer allowed, just 4 thumbnails were created as below.
FULL (700×394)
MEDIUM (300×169)
SQUARE (180×101)
LEAFLET (150×84)
THUMBNAIL (80×45)
Screen capture of Uploads – https://imgur.com/gallery/files-GSxY4FPSo forget about the 495 px image above, here’s the crux of the issue – I’d like to understand if this is correct behaviour or if there’s a problem with the image size being loaded by Android. My phone is a OnePlus 5, 5.5-inch display with a resolution of 1920×1080 pixels, the same pixel resolution as my desktop screen. As stated before, my desktop screen only ever shows the 180px image.
The new img code for the re-uploaded images lists all 5 image sizes above.
<img decoding="async" aria-describedby="caption-attachment-14027" class="wp-image-14027 size-square" src="https://www.americanroadtrips.net/wp-content/uploads/2024/10/Hotel-Nevada-2-180x101.jpg" alt="Hotel Nevada #2" width="180" height="101" srcset="https://www.americanroadtrips.net/wp-content/uploads/2024/10/Hotel-Nevada-2-180x101.jpg 180w, https://www.americanroadtrips.net/wp-content/uploads/2024/10/Hotel-Nevada-2-300x169.jpg 300w, https://www.americanroadtrips.net/wp-content/uploads/2024/10/Hotel-Nevada-2-80x45.jpg 80w, https://www.americanroadtrips.net/wp-content/uploads/2024/10/Hotel-Nevada-2-150x84.jpg 150w, https://www.americanroadtrips.net/wp-content/uploads/2024/10/Hotel-Nevada-2.jpg 700w" sizes="(max-width: 180px) 100vw, 180px">
#1 – The page specifies to display the Square thumbnail at 180px wide: if I am stating I want a 180 px image to display, why does srcset list the Medium and Full image sizes as options when these are larger than what the page code specifies? (i.e. how does srcset work? I wouldn’t have expected it to include larger image sizes than specified)
#2 – Remote Debug for Android says (I think) that the image actually being loaded on Android (the Intrinsic Size) is the Full size image, 700x394px at 35kB, and not any of the smaller thumbnails. Why is Android loading the Full size image (and not Square) – or am I incorrectly interpreting Remote Debug?
November 4, 2024 at 4:22 pm #1470583I last updated this support request a week ago but there has been no response since.
Is this being looked at or is there any update?
November 8, 2024 at 8:16 am #1470883Hi,
Sorry for the late response. Looks like the image with the size 495×279 is still being selected on smaller screens. Please try to add this code in the functions.php file to remove the size in the srcset attribute.
function avf_remove_specific_image_size_from_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) { foreach ( $sources as $source => $source_data ) { if ( strpos( $source, '495x279' ) !== false ) { unset( $sources[$source] ); } } return $sources; } add_filter( 'wp_calculate_image_srcset', 'avf_remove_specific_image_size_from_srcset', 10, 5 );
You can also disable the srcset completely by toggling the Enfold > Performance > Responsive Images option or by adding this code in the functions.php file:
add_filter( 'wp_calculate_image_srcset', '__return_false' );
Best regards,
IsmaelNovember 8, 2024 at 1:49 pm #1470906Please review the latter part of post #1470028.
I removed the 495px image from the equation to simplify matters.
The question now is why is Remote Debug for Android devices indicating that Android is loading the Full size (700x394px) image and not the Square (180x101px) specified? Yet on PC desktop the correct 180px image is being loaded. Or is Remote Debug wrong?
November 11, 2024 at 6:47 am #1471045Hi,
I removed the 495px image from the equation to simplify matters.
Yes, but this size is still included in the srcset attribute and is being selected for display on smaller screens. Did you try the filter above? It will remove the size from the srcset attribute, forcing the browser to select a different size.
Best regards,
IsmaelNovember 11, 2024 at 4:32 pm #1471096I added add_filter( ‘wp_calculate_image_srcset’, ‘__return_false’ ); and it did remove srcset completely.
I’d rather use the specific filter. However after removing the above and putting the specific filter in, srcset comes back into the page but the filter does not remove the 495px image from srcset. Purged caches and did a hard browser reload as well.
November 12, 2024 at 3:03 am #1471123Hi,
We adjusted the filter a bit. Please try it again:
function avf_remove_specific_image_size_from_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) { if ( isset( $sources[495] ) ) { unset( $sources[495] ); } return $sources; } add_filter( 'wp_calculate_image_srcset', 'avf_remove_specific_image_size_from_srcset', 10, 5 );
Best regards,
IsmaelNovember 12, 2024 at 3:15 pm #1471157That new code has removed the 495px image, thanks.
Next problem: Remote Debug for Android says (I think) that the image actually being loaded on Android (the Intrinsic Size) is now the Full size image, 700x394px at 37.1kB, and not any of the smaller thumbnails in srcset.
Why is Android loading the Full size image (and not Square, 180x101px at 5kB, as the page states) – or am I incorrectly interpreting Remote Debug? https://imgur.com/gallery/hotel-nevada-LAGkc3e
Dev Tools says desktop PC correctly loads the 180px size in responsive mode.
November 13, 2024 at 5:28 am #1471181Hi,
It seems to be loading the correct image (180x101px) on our end. Are you using any plugins related to images? Try to add this filter to force the browser to load the 180px image when the screen width is less than 768px.
add_filter( 'wp_calculate_image_srcset_sizes', 'avf_wp_calculate_image_srcset_sizes_mod', 10, 2 ); function avf_wp_calculate_image_srcset_sizes_mod( $sizes, $size ) { if ( 180 === $size[0] && 101 === $size[1] ) { return '(max-width: 768px) 180px, 700px'; } return $sizes; }
Best regards,
IsmaelNovember 13, 2024 at 3:30 pm #1471236I use Smush to compress and Simple Image Sizes to set custom image sizes.
That code has not made a difference, Remote Debug still says it is loading the 700px image.
But if you say it’s loading the correct image, then I’m OK with that and I’m not sure I need the extra code. I just wanted to make sure there wasn’t anything wrong with Enfold. Unless you’ve got other insight into what would cause Remote Debug to show the wrong size on my PC, I’ll just put this down to more dodgy code from Google…
One final question: on the ‘remove 495 image code’ if there were other sizes I wanted to get rid of, is this the code for multiple sizes?
if ( isset( $sources[495, 295] ) ) { unset( $sources[495, 295] );
November 14, 2024 at 3:44 am #1471283Hi,
One final question: on the ‘remove 495 image code’ if there were other sizes I wanted to get rid of, is this the code for multiple sizes?
For other sizes, you can duplicate the if block.
function avf_remove_specific_image_size_from_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) { if ( isset( $sources[495] ) ) { unset( $sources[495] ); } if ( isset( $sources[295] ) ) { unset( $sources[295] ); } return $sources; } add_filter( 'wp_calculate_image_srcset', 'avf_remove_specific_image_size_from_srcset', 10, 5 );
Best regards,
IsmaelNovember 14, 2024 at 3:00 pm #1471316Thanks, all done.
November 14, 2024 at 4:50 pm #1471321Hi,
Glad Ismael could help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Wrong thumbnail trying to load on Android phone’ is closed to new replies.