Cap the Largest Image Size in srcset
Stops browsers on large screens from downloading huge image versions by leaving very wide sizes out of the responsive srcset list.
Opens WPIDE on
Code
// Widest image (in pixels) a browser may pick from srcset.
$wpide_max_srcset_width = 1600;
add_filter( 'max_srcset_image_width', function () use ( $wpide_max_srcset_width ) {
return $wpide_max_srcset_width;
} );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.