WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#20666 closed defect (bug) (fixed)

Custom header image cropping can create identical attachments

Reported by: SergeyBiryukov Owned by: ryan
Milestone: 3.4 Priority: normal
Severity: normal Version: 3.4
Component: Appearance Keywords: has-patch
Focuses: 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 2 years ago.
20666.2.patch (591 bytes) - added by SergeyBiryukov 2 years ago.

Download all attachments as: .zip

Change History (7)

SergeyBiryukov2 years ago

comment:1 SergeyBiryukov2 years ago

  • Keywords has-patch added; needs-patch removed

comment:2 follow-up: ryan2 years 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.

SergeyBiryukov2 years ago

comment:3 SergeyBiryukov2 years ago

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

comment:4 in reply to: ↑ 2 SergeyBiryukov2 years 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 2 years ago by SergeyBiryukov (previous) (diff)

comment:5 ryan2 years ago

  • 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.