My WordPress website is generating thumbnails for my images I want to prevent WordPress from doing that how can I achieve the same?
CodePudding user response:
Consider searching for these particular problems, because this took me 5 seconds to find this plugin: https://wordpress.org/plugins/disable-generate-thumbnails/
CodePudding user response:
You can follow these steps for the same :
Step 1: In Admin Panel Go to Settings -> Media.
Step 2: Now Uncheck (Crop thumbnail) If it's Checked.
Step 3: Set at Thumbnail size, Medium size, and Large size the Width and Height to
CodePudding user response:
You may use the remove_image_size()
method like so:
add_action( 'init', 'so_73173777_remove_image_sizes' );
function so_73173777_remove_image_sizes() {
remove_image_size( '1200' );
remove_image_size( 'portfolio-full' );
remove_image_size( 'blog-medium' );
/* etc ... */
}
For removing default WP sizes:
add_filter( 'intermediate_image_sizes_advanced', 'so_73173777_remove_core_sizes' );
// This will remove the default image sizes and the medium_large size.
function so_73173777_remove_core_sizes( $sizes ) {
unset( $sizes['small']);
unset( $sizes['medium']);
unset( $sizes['large']);
unset( $sizes['medium_large']);
return $sizes;
}
CodePudding user response:
That code snippet combines all of the techniques required to disable all of WordPress generated images (leaving only the original uploaded image).
// disable generated image sizes
function hipl_disable_image_sizes($sizes) {
unset($sizes['thumbnail']); // disable thumbnail size
unset($sizes['medium']); // disable medium size
unset($sizes['large']); // disable large size
unset($sizes['medium_large']); // disable medium-large size
unset($sizes['1536x1536']); // disable 2x medium-large size
unset($sizes['2048x2048']); // disable 2x large size
return $sizes;
}
add_action('intermediate_image_sizes_advanced', 'hipl_disable_image_sizes');
// disable scaled image size
add_filter('big_image_size_threshold', '__return_false');
// disable other image sizes
function hipl_disable_other_image_sizes() {
remove_image_size('post-thumbnail'); // disable images added via set_post_thumbnail_size()
remove_image_size('another-size'); // disable any other added image sizes
}
add_action('init', 'hipl_disable_other_image_sizes');
The only editing that may be required is for that last function, where “other” image sizes are disabled; there you may want to edit the another-size slug to match any other sizes that you want to disable, or if there are no other sizes, simply comment out or remove the line.