Vajna Botond

Online Portofolio

Remove -scaled image

– Scaled image is the image WordPress generates when generating thumbnails, this is the maximum image size, and it`s not removable by the default remove_image_size(); or unset();

To remove it, add this filter to functions.php

add_filter( 'wp_generate_attachment_metadata', 'delete_fullsize_image' );
function delete_fullsize_image( $metadata ) {

    $upload_dir = wp_upload_dir();
    $full_image_path = trailingslashit( $upload_dir['basedir'] ) . $metadata['file'];
    $deleted = unlink( $full_image_path );

    return $metadata;
}