[wp-trac] [WordPress Trac] #15989: image_resize_dimensions() mistakenly defaults crop center as image's center of gravity.
WordPress Trac
wp-trac at lists.automattic.com
Mon Dec 27 02:41:49 UTC 2010
#15989: image_resize_dimensions() mistakenly defaults crop center as image's center
of gravity.
-------------------------+-------------------------------------------------
Reporter: jacof | Owner:
Type: defect | Status: new
(bug) | Milestone: Awaiting Review
Priority: normal | Version: 3.1
Component: Post | Keywords: Thumbnails, Resizing, Rescaling,
Thumbnails | Cropping
Severity: major |
-------------------------+-------------------------------------------------
WordPress add_image_size() routine calls ultimately for
image_resize_dimensions(), which calculates the cropped image dimensions.
(http://core.trac.wordpress.org/browser/tags/3.0.3/wp-
includes/media.php#L333)
The function assumes that the cropping center is always the gravity center
of the image, whereas the user must be able to select where and how the
cropping will be made.
{{{
$s_x = floor( ($orig_w - $crop_w) / 2 );
$s_y = floor( ($orig_h - $crop_h) / 2 );
}}}
Due to this, custom thumbnails result cropped around wrong centers.
WordPress' Editor inside the Multimedia dialog doesn't affect post
thumbnails defined by the user's theme, but only the thumbnails defined in
the admin, as it doesn't regenerate them after rescaling the image. A
temporary fix is regenerating all of the thumbnails using a third party
plugin ("Regenerate Post Thumbnails"). This temporary fix generates
(#Thumbs)*(#Images)*(#Resizes)+(#Images) in the Server, which is over
demanding.
Fixing the Wordpress Editor to affect post-thumbnails (as it should) would
not be a proper fix, since the user must not be constrained to reducing
the dimensions of his/her image as a whole in order to produce a correct
thumbnail.
The two solutions feasable for this are:
1- Correct the Wordpress Multimedia Editor to regenerate thumbnails after
rescaling the image (short-term).
2- Modify image_resize_dimensions() to accept optional $x=0, $y=0 and
allowing, ultimately, the selection of those values in the Multimedia
Editor by the user, for each image, and for each thumbnail.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15989>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list