Opened 13 years ago
Closed 10 years ago
#19793 closed defect (bug) (fixed)
In image editor, editing thumbnail has no effect if crop is exactly size of thumbnail
Reported by: | janmakinen | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.1 | Priority: | normal |
Severity: | minor | Version: | 3.3.1 |
Component: | Media | Keywords: | has-patch |
Focuses: | javascript | Cc: |
Description
When you upload some image, by the default 'thumbnail', 'medium' and 'large' sizes of this image are generated.
You can re-crop them by clicking on 'edit image' link.
If you check 'Thumbnail' on 'Apply changes to:', only 'thumbnail' size will be re-cropped (thats how I understand this feature).
But.
If you set 'Selection' in 'Image Crop' to actual 'thumbnail' size set in 'Media' page of the settings, nothing will be re-cropped and saved (first problem). Once you try, you lose the ability to check 'Apply changes to' option on the 'Edit image' screen, it disappears (second one).
How to reproduce.
Set 'thumbnail' in settings to '280x210'. Check crop option.
Upload some big image (bigger than 'thumbnail' size), click on 'Edit image' link in image edit screen.
Make a selection on image.
Find 'Image Crop' section. Don't fill 'Aspect ratio' (not tested), fill 'Selection' with '280' and '210'.
Set 'Thumbnail' in 'Apply changes to'.
Click on crop icon, and then on 'Save' button.
Get a response 'Image saved'.
You fill like you have re-cropped 'thumbnail' size of the image and new one was generated. It didn't.
Go to uploads folder, try to find your new thumbnail. There is still a previous one.
Something strange happened.
After this, inside '_wp_attachment_backup_sizes' of re-cropped attachment, we get 'thumbnail-orig' item. Its ok.
If you check '_wp_attachment_metadata', you won't find 'thumbnail' item anymore. Its disappeared. Like you don't have 'thumbnail' size set.
Thats strange. Logically, it should contain link to re-cropped thumbnail.
Tested on 3.3 and 3.3.1.
Attachments (1)
Change History (10)
#4
@
10 years ago
- Summary changed from 'thumbnail' edit doesn't work to In image editor, editing thumbnail has no affect if crop is exactly size of thumbnail
#5
@
10 years ago
- Summary changed from In image editor, editing thumbnail has no affect if crop is exactly size of thumbnail to In image editor, editing thumbnail has no effect if crop is exactly size of thumbnail
#6
@
10 years ago
- Focuses javascript added
- Milestone changed from Awaiting Review to 4.1
- Owner set to ericlewis
- Status changed from new to reviewing
What do you suggest?
#7
@
10 years ago
- Keywords has-patch added
I took a look at this and found the culprit:
// if the resulting image would be the same size or larger we don't want to resize it if ($new_w >= $orig_w && $new_h >= $orig_h) return false;
Looks like this code has been this way since `image_resize_dimensions()` was added.
Patch forthcoming which accounts for the condition when the destination width is the same as the original (selected) width, and the destination height is the same as the original height. Current unit tests pass, and I added a single unit test for image_resize_dimensions()
.
Open to suggestions for other unit tests to add, or if anyone can think of any situations where this would not work or would cause unexpected behavior.
As of current trunk version, the bug can't be reproduced as janmakinen detailed. When you set the selection width and height to the same value as the thumbnail size, the crop button is disabled.