[wp-trac] [WordPress Trac] #46777: Pass attachment ID to image_resize_dimensions to allow reliable per image cropping

WordPress Trac noreply at wordpress.org
Sat Apr 13 09:43:09 UTC 2019


#46777: Pass attachment ID to image_resize_dimensions to allow reliable per image
cropping
-------------------------+------------------------------
 Reporter:  arkimedia    |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Media        |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  administration
-------------------------+------------------------------

Comment (by arkimedia):

 I'm building a plugin which allows admins to select a focal point of an
 image. Plugin stores focal point data to attachment metadata and uses
 `image_resize_dimensions` filter to calculate best cropping area for each
 image size.

 Currently I've used a editor subclass, but filter would be better
 alternative, because it makes possible to implement solution that works
 whit every image editor class.

 And even I'd use subclass, currently the attachment ID won't get passed to
 the `multi_resize` method of the image editor class, so I have to resolve
 the ID from the image path, which has some performance downsides.
 https://github.com/WordPress/WordPress/blob/71cf332e6569f0ac2f263ce9b2168644942f5534
 /wp-admin/includes/image.php#L145

 In other words passing the attachment id to the `multi_resize` method is
 minimum requirement, but passing it to the `image_resize_dimensions`
 filter makes possible to implement image editor independent solution.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46777#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list