Maybe I’m not understanding how this is supposed to work, but I’m trying to use the code found on this page for Display Image (ID).
In my example, I have the size set to medium_large, but no matter what size screen I’m viewing the site on, it always displays the medium_large image, which in turn makes any page speed test throw a fit because it’s too large for mobile devices.
I was under the impression that this would, for lack of better phrasing, look at the viewport size and only load the most properly sized image. I checked the uploads, and there are definitely sizes available that are smaller (three of them actually).
My code
<?php
$image = get_field('sponsors_image');
$size = 'medium_large';
if( $image ) {
echo wp_get_attachment_image( $image, $size, '', array('class' => 'img-fluid border', 'loading' => 'lazy') );
} ?>
Here’s a Test Page with code in action.
Thanks in advance for any assistance/clarification.