WordPress.org

Make WordPress Core

Ticket #15989: media.diff

File media.diff, 731 bytes (added by buzz_matt, 2 years ago)

Add filter to allow crop location alterations

  • media.php

     
    360360 
    361361                $s_x = floor( ($orig_w - $crop_w) / 2 ); 
    362362                $s_y = floor( ($orig_h - $crop_h) / 2 ); 
     363                 
     364                // allow the location of the crop to be altered 
     365                // the returned array should be the x,y coords of the top left corner of the cropping region 
     366                if (has_filter( 'image_crop_location' )) { 
     367                        list($s_x,$s_y) = apply_filters( 'image_crop_location', $orig_w, $orig_h, $crop_w, $crop_h, $s_x, $s_y ); 
     368                        $s_x = intval($s_x); 
     369                        $s_y = intval($s_y); 
     370                } 
    363371        } else { 
    364372                // don't crop, just resize using $dest_w x $dest_h as a maximum bounding box 
    365373                $crop_w = $orig_w;