image_resize_dimensions() mistakenly defaults crop center as image's center of gravity.
|Reported by:||jacof||Owned by:||nacin|
|Cc:||jacof, scott@…, gabriel.koen@…, matt@…, ben@…|
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.
Change History (35)
comment:4 markjaquith — 2 years ago
- Milestone changed from Awaiting Review to Future Release
- Owner set to markjaquith
- Status changed from new to assigned
comment:5 SergeyBiryukov — 2 years ago
- Keywords has-patch added; Thumbnails Resizing Rescaling Cropping removed
comment:10 nacin — 16 months ago
- Milestone changed from Future Release to 3.4
- Resolution set to fixed
- Status changed from assigned to closed
comment:11 ocean90 — 16 months ago
- Keywords dev-feedback 2nd-opinion removed
- Resolution fixed deleted
- Status changed from closed to reopened
comment:12 nacin — 16 months ago
- Owner changed from markjaquith to nacin
- Status changed from reopened to accepted