3

This is my first question, so forgive me if it's not perfect 😅

I am asking, if there is a way, to completely disable and remove the thumbnail functionality from WordPress. (I am using an image CDN plugin, which is taking care of resizing, optimizing, etc. So, no need for the extra size and file count consumption by thumbnails)

I already know how to prevent WordPress from generating thumbnails, good so far. I also know how to delete all thumbnails (from the filesystem). But doing this on my staging environment brought up 2 obvious issues I forgot about.

To prevent the issues, I would need functions, that:

Removes all thumbnail information from the WordPress database (i guess postmeta?)

"Replaces" the image size Settings, of all images used in Blog-posts or Pages, by "Full Size"

enter image description here

"Replaces" the thumbnails, used by the media library, with the full-sized image (since I want to delete all thumbnails)

Meida Library Thumbnail Link

Thanks in advance

1 Answer 1

0

To remove all extra image sizes you use get_intermediate_image_sizes() in tandem with remove_image_size(). E.g.

function remove_extra_image_sizes() {
  array_map( 'remove_image_size', get_intermediate_image_sizes() );
} 
add_action('init', 'remove_extra_image_sizes');

To edit the image size dropdown you can hook a custom function to image_size_names_choose filter.

function filter_image_size_names_choose($size_names) {
  return array_filter( $size_names, function( $size_name ){
    return 'full' === $size_name;
  }, ARRAY_FILTER_USE_KEY );
}
add_filter('image_size_names_choose', 'filter_image_size_names_choose');

Then use some thumbnail plugin to "regenerate" thumbnails. As the sizes are disabled the plugin should (in theory) just clean up any existing thumbnail files and data, leaving you with just the full size images.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.