# 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.

- Type: PHP
- Runs: Run everywhere
- Category: [Performance](https://wpide.com/library/category/performance/)
- Tags: performance, images, responsive
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/cap-srcset-image-width/

## Code

```php
// 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 use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Cap the Largest Image Size in srcset" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
