WordPress.org

Make WordPress Core

Ticket #9672: image_downsize.patch

File image_downsize.patch, 1014 bytes (added by scribu, 5 years ago)

apply the filter at the end

  • wp-includes/media.php

     
    133133        $width = $height = 0; 
    134134        $is_intermediate = false; 
    135135 
    136         // plugins can use this to provide resize services 
    137         if ( $out = apply_filters('image_downsize', false, $id, $size) ) 
    138                 return $out; 
    139  
    140136        // try for a new style intermediate size 
    141137        if ( $intermediate = image_get_intermediate_size($id, $size) ) { 
    142138                $img_url = str_replace(basename($img_url), $intermediate['file'], $img_url); 
     
    163159                // we have the actual image size, but might need to further constrain it if content_width is narrower 
    164160                list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size ); 
    165161 
    166                 return array( $img_url, $width, $height, $is_intermediate ); 
     162                $data = array( $img_url, $width, $height, $is_intermediate ); 
     163 
     164                return apply_filters('image_downsize', $data, $id, $size); 
    167165        } 
    168166        return false; 
    169167