How to removes all instances of thumbnails displayed in my theme?

basically I’d like all thumbnails mentions to be replaced by an empty string or something like that. Some piece of code I can just add to a plugin or functions.php

Solutions Collecting From Web of "How to removes all instances of thumbnails displayed in my theme?"

Doing such thing by replacing the URL is not recommended, for a variety of reasons. One for example is that if you do this, your thumbnails won’t be deleted after you delete the original image, since you have broken the link in the database.

Another reason is that if you try to access a default-size generated thumbnail, it will redirect to a simple page load. For example:


This means a full request to the homepage, loading every asset, requesting more links, and go on.

The correct approach would be to unset the default sizes. You can hook into intermediate_image_sizes_advanced filter and do this:

function unset_default_thumbnails( $sizes) {
    unset( $sizes['thumbnail']);
    unset( $sizes['medium']);
    unset( $sizes['medium-large']);
    unset( $sizes['large']);

    return $sizes;
add_filter('intermediate_image_sizes_advanced', 'unset_default_thumbnails');

Done. Now, there will be no generated thumbnails after you upload an image. Your own thumbnail sizes still will be generated.

To delete the current thumbnails, you can use the popular Thumbnail Cleaner plugin.


Based on your comments, I’ve added a way to replace the URLs generated by the_post_thumbnail() with an empty string. This is not recommended.

add_filter( 'post_thumbnail_html', 'disable_post_thumbnails' ,10 , 5 );
function disable_post_thumbnails( $html, $post->ID, $post_thumbnail_id, $size, $attr ){
    // Check if the image is true
    if ( $html ) {
        switch ( $size ) {
            case 'post-thumbnail':
            case 'thumbnail':
            case 'medium':
            case 'medium-large':
            case 'large':
                // Let's replace the thumbnail's URL with the
                // website's URL for only the default sizes
                $html = str_replace( $html , '<img src="'.site_url().'"/>' , $html );
    // Return the URL
    return $html;

Please notice, once a function is declared you can’t just remove it. What you can do is to filter it’s input/output, if it does support that.

PS: this can break plugin/theme’s behavior. This is just for educational purposes, do not try this at home.