Deluxe Blog Tips About Projects

Change Default Max Image Size For WordPress Theme

In WordPress themes, post content often has specified width. Thus, images which has bigger size than content width can break up the layout of theme. To prevent this situation, WordPress provides one way to specify the maximum image size for themes.

To define the maximum image size, just paste the following line into your functions.php file:

$content_width = 400;

Change 400 to any number (which is the maximum width of images) you want.

After that, when you upload any image when posting, you’ll see the maximum image width is set to 400px as in the following screenshot:

Change Default Max Image Size For WordPress Theme

This setting will overwrite the settings in the Settings → Media menu.

Subscribe to the Newsletter

Subscribe to get my latest content by email. I won't send you spam. Unsubscribe at any time.