Opened 6 years ago
Last modified 13 months ago
#44127 new defect (bug)
editing an image can result in intermediate sized images left over after the image is deleted
Reported by: | pbiron | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.9.5 |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description
Steps to reproduce:
- set thumbnail_size to
150x150
- upload a
300x300
image, e.g.,foo.jpg
- will result in
/wp-content/uploads/foo-150x150.jpg
being generated
- will result in
- edit the image and scale to
200x200
- will result in something like
/wp-content/uploads/foo-e1526583456941.jpg
being generated /wp-content/uploads/foo-150x150.jpg
will still be present, since it is still a valid thumbnail for the scaled image
- will result in something like
- regenerate intermediate sized images (e.g., by calling wp_get_attachment_metadata() followed by wp_update_attachment_metadata(), which the Regenerate Thumbnails plugin does)
- will result in something like
/wp-content/uploads/foo-e1526583456941-150x150.jpg
being generated
- will result in something like
- "Delete Permanently" the image
Check /wp-content/uploads
and you will see that foo-150x150.jpg
is still there.
Attachments (4)
Change History (14)
This ticket was mentioned in Slack in #core-media by pbiron. View the logs.
6 years ago
This ticket was mentioned in Slack in #core-media by pbiron. View the logs.
6 years ago
This ticket was mentioned in Slack in #core-media by pbiron. View the logs.
6 years ago
This ticket was mentioned in Slack in #core-media by pbiron. View the logs.
6 years ago
@
6 years ago
There are currently no unit tests for the creation/modification of the _wp_attachment_backup_sizes
postmeta by wp_save_image()
. So, before moving forward with a patch for this ticket I'm proposing these tests as benchmark on existing behavior. Add this file to /tests/phpunit/tests/ajax.
@
6 years ago
This is a phpunit config file to run those tests in MediaEditBackupSizes.php
that depend on IMAGE_EDIT_OVERWRITE
being false (or are agnostic to its value). Add this file to /tests/phpunit
and then run phpunit -c tests/phpunit/MeditEditBackupSizes.xml
@
6 years ago
This is a phpunit config file to run those tests in MediaEditBackupSizes.php
that depend on IMAGE_EDIT_OVERWRITE
being true (or are agnostic to its value). Add this file to /tests/phpunit
and then run phpunit -c tests/phpunit/MeditEditBackupSizesImageEditOverwrite.xml
#6
@
6 years ago
This is the 1st of several comments calling out specific questions in the unit tests.
I wrote tests for how scale
and crop
effect _wp_attachment_backup_sizes
but not for rotate
and flip
because it doesn't seem to me that they were necessary as those operations produce the same mods on _wp_attachment_backup_sizes
as crop
does.
Can someone who knows the code better than I do confirm that tests for rotate
and flip
aren't necessary?
#7
@
6 years ago
Argh!!! I just discovered a MAJOR bug with the tests and found they are not testing what I thought they were testing. I'll upload another version when I get that bug fixed.
@
6 years ago
This fixes the bug I just mentioned. Do not use MediaEditBackupSizes.php
!!! The bug was that the $_REQUEST
array wasn't being emptied before setting up each new request; as a result, the testScaleImageImageEditOverwrite()
and testMultipleScaleImageImageEditOverwrite()
were actually doing the crop
from the previous test instead of the scale
they were supposed to be doing and I had constructed the $expected
value for that "incorrect" operation rather than what it should it should have been. This version corrects those tests as well as fixing _setUpRequest()
.
#8
@
6 years ago
We now return you to your regularly scheduled questions :-)
Does anyone think there is a need for a test that includes a scale
and a crop
on the same image?
There are probably a number of ways to address this but my suggestion is:
_wp_attachment_backup_sizes
postmeta to contain the info in thesizes
portion of thewp_attachment_metadata
postmeta