WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 7 months ago

#17542 closed enhancement (invalid)

Remove upload file after deleting custom background

Reported by: denzel_chia Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Customize Keywords: has-patch
Focuses: administration Cc:

Description

I came across a comment on custom-background.php that says
@todo: uploaded files are not removed here.

So, I thought I will come up with this codes for the upload file deletion if user remove background.

Attached custom-background.diff

I had tested on my localhost.

Hope this contribution is useful.

Thanks.

Attachments (2)

custom-background.diff (1.5 KB) - added by denzel_chia 4 years ago.
17542.diff (1.5 KB) - added by kawauso 4 years ago.
Delete on reset and check for attachment ID

Download all attachments as: .zip

Change History (8)

comment:1 @ocean904 years ago

You should use the current trunk, there is a revert in your patch, see 'context' => 'custom-background' .

comment:2 @kawauso4 years ago

  • Keywords has-patch added

Not got a theme to test this with, but shouldn't we delete the attachment on reset as well?

Attaching a patch that does this and checks we actually have an attachment ID before trying to delete it.

@kawauso4 years ago

Delete on reset and check for attachment ID

comment:3 @denzel_chia4 years ago

Thanks everybody for the pointers.

comment:4 @nacin4 years ago

Nice initial work on this, both of you.

Because backgrounds are now stored with context => custom-background, then we're actually remembering previous backgrounds. Keeping the old background around after settings changes doesn't seem like a problem. But I'll leave that for the UX.

comment:5 @nacin18 months ago

  • Component changed from Administration to Appearance
  • Focuses administration added

comment:6 @celloexpressions7 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

4 years later, now that backgrounds are handled through the media library (and in the Customizer, see [30309], and [30459]), they definitely shouldn't be deleted when they're removed/changed from the background setting, since they can also be used elsewhere. So this ticket is no longer relevant.

Note: See TracTickets for help on using tickets.