#20666 closed defect (bug) (fixed)

Custom header image cropping can create identical attachments

Reported by: SergeyBiryukov Owned by: ryan
Priority: normal Milestone: 3.4
Component: Appearance Version: 3.4
Severity: normal Keywords: has-patch
Cc:

Description

  1. Add an image to Media Library which requires cropping.
  2. Go to Appearance → Header, click "Choose from image library".
  3. Select the image from point 1, click "Set as header", "Crop and Publish".
  4. Press browser's Back button, click "Crop and Publish" once again.
  5. Delete one of the two identical "Header Image" attachments in Media Library.
  6. The other attachment is now orphaned (the files are deleted in point 5).

Sounds like wp_unique_filename() should be used in there somewhere.

Related: #19840, #20657

Attachments (2)

20666.patch (583 bytes) - added by SergeyBiryukov 13 months ago.
20666.2.patch (591 bytes) - added by SergeyBiryukov 13 months ago.

Download all attachments as: .zip

Change History (7)

  • Keywords has-patch added; needs-patch removed

comment:2 follow-up: ↓ 4   ryan13 months ago

Perhaps we should also call wp_upload_dir() to get a newly dated upload dir instead of reusing the old dir when cropping an existing image from the media library.

20666.2.patch fixes the line placement (should be after wp_mkdir_p()).

comment:4 in reply to: ↑ 2   SergeyBiryukov13 months ago

Replying to ryan:

Perhaps we should also call wp_upload_dir() to get a newly dated upload dir instead of reusing the old dir when cropping an existing image from the media library.

step_3() in wp-admin/custom-header.php would still expect the new attachment to be in the same directory as the original file:
http://core.trac.wordpress.org/browser/trunk/wp-admin/custom-header.php?rev=20769#L877

Last edited 13 months ago by SergeyBiryukov (previous) (diff)
  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [20787]:

Make the file names unique for cropped header images. Props SergeyBiryukov. fixes #20666

Note: See TracTickets for help on using tickets.