WordPress automatically generates multiple thumbnail sizes for uploaded images, including 150×150 pixels (thumbnail), 300×300 pixels (medium), 768×768 pixels (medium_large), 1024×1024 pixels (large), and other custom sizes. These auto-generated images can consume significant server space, especially when uploading large numbers of images. If you don’t need these cropped images, including the 768px medium_large size, you can disable WordPress’s image cropping functionality. This article details how to achieve this using the hidden /wp-admin/options.php page, code modifications, and plugins.
Why Disable Image Cropping?
- Save Server Space: Each uploaded image generates multiple size variants, increasing storage demands.
- Improve Upload Efficiency: Disabling cropping reduces the time needed to generate thumbnails.
- Simplify Image Management: Retaining only the original image reduces file management complexity.
- Meet Specific Project Needs: Some websites may only require original images or specific sizes.
Method 1: Disable Cropping via /wp-admin/options.php
WordPress’s /wp-admin/options.php is a hidden admin page that allows direct modification of settings stored in the wp_options database table. You can use this page to adjust image cropping settings, such as disabling the 768px medium_large size.
Steps:
- Log in to your WordPress admin panel and enter yourwebsite.com/wp-admin/options.php in your browser’s address bar (e.g., https://example.com/wp-admin/options.php).
- The page will display a long form listing all WordPress settings. Locate the following fields:
- medium_large_size_w: Default value is 768, representing the medium_large width.
- medium_large_size_h: Default value is 0 (height is adaptive).
- Set both medium_large_size_w and medium_large_size_h to 0 to disable the 768px medium_large size.
- Scroll to the bottom of the page and click the “Save Changes” button.
Notes:
- Risk of Direct Modification: The options.php page directly edits database settings, and incorrect changes can break your site. Back up your database before proceeding.
- Limited Scope: This method is primarily for disabling the 768px medium_large size. To disable all thumbnail sizes, combine with Method 2.
- Permission Requirements: Accessing options.php requires administrator privileges.
Method 2: Disable Cropping in the Theme’s functions.php File
You can completely disable WordPress’s image cropping, including the 768px medium_large size, by modifying the theme’s functions.php file.
Steps:
- Log in to your WordPress admin panel, navigate to Appearance > Theme File Editor, and locate the functions.php file. Alternatively, use FTP/SFTP to access wp-content/themes/your-theme/functions.php.
- Add the following code to the end of the functions.php file:
// Disable all image size cropping
add_filter('intermediate_image_sizes_advanced', '__return_empty_array');
// Disable 768px medium_large size only
add_filter('intermediate_image_sizes', function($sizes) {
return array_diff($sizes, ['medium_large']);
});
- Save the file.
Notes:
- The intermediate_image_sizes_advanced filter disables all auto-generated thumbnail sizes.
- To disable only the 768px medium_large size, use the second add_filter code alone.
- Always back up the functions.php file before editing to avoid errors.
Method 3: Disable Cropping Using a Plugin
For users uncomfortable with code, plugins like Disable Media Sizes or Simple Image Sizes offer a user-friendly way to disable image cropping.
Using Disable Media Sizes Plugin:
- In the WordPress admin panel, go to Plugins > Add New, search for “Disable Media Sizes.”
- Install and activate the plugin.
- Navigate to the plugin’s settings page (typically under Settings > Media or a dedicated plugin settings page).
- Uncheck the image sizes you don’t need, including medium_large (768px).
- Save the settings.
Advantages:
- No coding required, ideal for non-technical users.
- Allows flexible selection of which sizes to disable.
Method 4: Set Maximum Image Width in wp-config.php
To retain only the original image, you can set the maximum image width to 0, effectively disabling cropping.
Steps:
- Access your WordPress installation directory and locate the wp-config.php file (usually in the root directory).
- Add the following code before the line /* That’s all, stop editing! */:
define('IMAGE_EDIT_OVERWRITE', true);
add_filter('wp_image_editors', function() {
return array('WP_Image_Editor_GD', 'WP_Image_Editor_Imagick');
});
set_post_thumbnail_size(0, 0);
add_filter('intermediate_image_sizes', '__return_empty_array');
- Save the file.
Notes:
- This method forces WordPress to stop generating thumbnails.
- If your theme or plugins rely on specific image sizes, further adjustments may be needed.
Important Considerations
- Handling Existing Images: Disabling cropping only affects newly uploaded images. Existing thumbnails must be manually removed using plugins like Regenerate Thumbnails or Force Regenerate Thumbnails.
- Theme and Plugin Compatibility: Some themes or plugins may depend on specific image sizes (e.g., 768px medium_large). Verify that disabling cropping doesn’t affect site functionality.
- Backup Critical Files: Before modifying functions.php, wp-config.php, or using /wp-admin/options.php, back up files and the database to prevent issues.
- CDN and Caching: If you use a CDN or caching plugin, clear the cache after disabling cropping to ensure changes take effect.
- Risk of Using options.php: Direct modifications via /wp-admin/options.php require caution and are recommended only for experienced administrators.
Cleaning Up Existing Thumbnails
To remove existing thumbnail files after disabling cropping:
- Install and activate the Regenerate Thumbnails plugin.
- Go to Tools > Regenerate Thumbnails.
- Select the “Delete all unused thumbnails” option and run the cleanup.
- Alternatively, use FTP/SFTP to manually delete thumbnail files from the wp-content/uploads directory (ensure you don’t delete original images).
Conclusion
Disabling WordPress’s image cropping functionality, including the 768px medium_large size, can be achieved using the hidden /wp-admin/options.php page, modifying functions.php, using plugins, or adjusting wp-config.php. The /wp-admin/options.php method offers a direct way to disable the 768px size but requires caution due to its low-level access. For complete control or to disable all thumbnails, combine with code-based methods. Choose the method that best suits your technical expertise and needs. Always ensure site functionality remains intact and maintain regular backups of files and the database.
By following these steps, you can reduce server space usage, improve image upload efficiency, and meet specific project requirements.