Media PHP Beginner

Change the Size WordPress Scales Large Images To

Change the 2560 px limit WordPress uses to scale down huge uploaded photos, for example to 1920 px.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 3 lines
add_filter( 'big_image_size_threshold', function (): int {
	return 1920;
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

When you upload a photo wider or taller than 2560 pixels, WordPress saves a scaled-down copy and uses that as the “full” image. If your site never shows images that large, a lower limit saves a lot of storage and bandwidth.

How it works

The big_image_size_threshold filter sets the maximum width or height of the image WordPress uses as the full size. Images larger than that are scaled down on upload and saved with -scaled in the name. The untouched original is kept on disk as a backup.

Things to watch

  • Only new uploads are affected.
  • Don’t go below the widest size your theme displays, or images will look soft on large screens.
  • Returning false turns scaling off completely, which keeps huge originals in use. That’s rarely what you want.

How to test it

Upload a photo wider than 1920 px. In the Media Library, its dimensions should show a width of 1920 px.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only