When an image file is uploaded to WordPress, various copies of the image is created and stored. Normally, three additional copies of an image will be stored with the original one. These copies are different in terms of dimension or image size (Width X Height pixels). The WordPress Media Manager, automatically re-sizes the images and stores it in the same location as the original one but with a different file name.
You might be interested in: How to Change WordPress Media Upload Folder.
The three default image dimensions are:
- Thumbnail (Maximum width: 150px; Maximum Height: 150px)
- Medium (Maximum width: 300px; Maximum Height: 300px)
- Large (Maximum width: 1024px; Maximum height: 1024px)
Note that the other image dimension is called Full Size which just happens to be the original image. If the original image is smaller than the maximum dimension limit, then larger images are not generated.
For example: An image originally 200 X 200 in width and height won’t have medium and large image sizes.
Changing the Default Image Dimensions
It is possible to change the default image dimensions for images that are uploaded. You can specify the size of thumbnails, medium and large images which are generated automatically.
From WordPress Dashboard
For changing the default dimensions of the thumbnail, medium and large size images:
- In WordPress dashboard, access Settings > Media.
- Enter the maximum values for the width and height of the three image sizes.
Editing Theme’s functions.php
It is also possible by editing the present theme’s functions.php file located in /wp-content/themes/<active-theme>/ using FTP, a File Manager or WordPress Appearance Editor.
Tip: Create a child theme and edit its function.php to retain the changes after the theme is upgraded.
Add the following lines of code, along with your own values:
For Updating Thumbnail Size
[php toolbar=”false”]update_option( ‘thumbnail_size_w’, 200 );
update_option( ‘thumbnail_size_h’, 200 );
update_option( ‘thumbnail_crop’, 1 );[/php]
For Updating Medium Image Size
[php toolbar=”false”]update_option( ‘medium_size_w’, 450 );
update_option( ‘medium_size_h’, 300 );[/php]
For Updating Large Image Size
[php toolbar=”false”]update_option( ‘large_size_w’, 800 );
update_option( ‘large_size_h’, 600 );[/php]
Note that this overrides the values from Settings > Media. Also, note that when the crop option is not set (or is set to false or 0), you are essentially setting maximum size of width or height. It maintains the original aspect ratio.
When either one size limit is met, the image dimension is limited. So an image with a full size of 1080 X 1920 will have a large size of 338 X 600, because the width limit 600 is met. If the crop option was set to 1 or true by using
[php light=”true”]update_option(‘large_crop’, 1)[/php]
Then the size will be forced to 800 X 600 with cropping.
Note: Both these options to change the default media dimensions will only work on future image uploads. To regenerate these new media sizes for old images use the plugin: Regenerate Thumbnails.
File Names
Since images of various sizes are stored in the same directory, they are differentiated using of file names. If you haven’t noticed already, the file names will have the dimensions along with them. There won’t be a dimension for the original file name.
Example:
Original Image: image.jpg
Thumbnail: image-150x150.jpg
Medium: image-300x241.jpg
Large: image-825x510.jpg
Further reading: How to Create Additional Sizes of Images for Uploads