Image srcset issue with custom image sizes

Hello,

I’m adding a few new image sizes within extras.php as follows;

add_image_size(‘w360’, 360, 9999);

And adding it to the theme;

the_post_thumbnail( ‘w360’ );

But the output includes all the image versions via the srcset;

The issue is I don’t need to user to view an alternative image, or have to download another version, or bulk up the page weight. Is there anyway to turn this off?

Many thanks, Stephen

img width=“360” height=“240” src="/wp-content/uploads/2016/12/12694745_10154602516469832_9080468248028016260_o-Copy-360x240.jpg" class=“attachment-w360 size-w360 wp-post-image” alt=“12694745_10154602516469832_9080468248028016260_o-copy” srcset="/wp-content/uploads/2016/12/12694745_10154602516469832_9080468248028016260_o-Copy-360x240.jpg 360w, /wp-content/uploads/2016/12/12694745_10154602516469832_9080468248028016260_o-Copy-300x200.jpg 300w, /wp-content/uploads/2016/12/12694745_10154602516469832_9080468248028016260_o-Copy-768x512.jpg 768w, /wp-content/uploads/2016/12/12694745_10154602516469832_9080468248028016260_o-Copy-1024x683.jpg 1024w, /wp-content/uploads/2016/12/12694745_10154602516469832_9080468248028016260_o-Copy-800x533.jpg 800w, /wp-content/uploads/2016/12/12694745_10154602516469832_9080468248028016260_o-Copy-640x427.jpg 640w" sizes="(max-width: 360px) 100vw, 360px"

Unrelated to Sage - you can disable WP responsive images with:

add_filter('wp_calculate_image_srcset_meta', '__return_null');
1 Like

The issue is I don’t need to user to view an alternative image, or have to download another version, or bulk up the page weight. Is there anyway to turn this off?

srcsets don’t download additional images, they let the browser decide what is the best image to download for the given screen width and pixel density.

1 Like

srcset/sizes are awesome and I always embrace them. Preparing the right sizes attribute can be tricky sometimes but it is really worth the bandwidth and visual (hidpi) improvements.

1 Like