WordPress.org

Make WordPress Core

Ticket #6142: remove-intermediate-images-r7201.patch

File remove-intermediate-images-r7201.patch, 1.8 KB (added by tellyworth, 7 years ago)
  • wp-includes/post.php

     
    21802180                } 
    21812181        } 
    21822182 
     2183        // remove intermediate images if there are any 
     2184        $sizes = apply_filters('intermediate_image_sizes', array('thumbnail', 'medium')); 
     2185        foreach ( $sizes as $size ) { 
     2186                if ( $intermediate = image_get_intermediate_size($postid, $size) ) { 
     2187                        $intermediate_file = apply_filters('wp_delete_file', $intermediate['path']); 
     2188                        @ unlink($intermediate_file); 
     2189                } 
     2190        } 
     2191 
    21832192        $file = apply_filters('wp_delete_file', $file); 
    21842193 
    21852194        if ( ! empty($file) ) 
  • wp-includes/media.php

     
    7979                list( $width, $height ) = image_constrain_size_for_editor( $meta['width'], $meta['height'], $size ); 
    8080        } 
    8181 
    82         return array( $img_url, $width, $height ); 
     82        if ( $img_url) 
     83                return array( $img_url, $width, $height ); 
     84        return false; 
    8385 
    8486} 
    8587 
     
    253255        if ( empty($imagedata['sizes'][$size]) ) 
    254256                return false; 
    255257                 
    256         return $imagedata['sizes'][$size]; 
     258        $data = $imagedata['sizes'][$size]; 
     259        // include the full filesystem path of the intermediate file 
     260        if ( empty($data['path']) && !empty($data['file']) ) { 
     261                $file_url = wp_get_attachment_url($post_id); 
     262                $data['path'] = path_join( dirname($imagedata['file']), $data['file'] ); 
     263                $data['url'] = path_join( dirname($file_url), $data['file'] ); 
     264        } 
     265        return $data; 
    257266} 
    258267 
    259268// get an image to represent an attachment - a mime icon for files, thumbnail or intermediate size for images 
     
    290299        return $html; 
    291300} 
    292301 
    293  
    294302add_shortcode('gallery', 'gallery_shortcode'); 
    295303 
    296304function gallery_shortcode($attr) {