Make WordPress Core

Opened 17 years ago

Closed 16 years ago

#12467 closed defect (bug) (fixed)

deleting the header and background images from media / library doesn't invalidate these files for the theme

Reported by: Denis-de-Bernardy Owned by: nacin
Priority: normal Milestone: 3.0
Component: Template Version: 3.0
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

when they're deleted, the theme options should get reset accordingly.

Attachments (1)

12467.patch (890 bytes ) - added by ocean90 16 years ago.

Download all attachments as: .zip

Change History (6)

#1 @ocean90
16 years ago

  • Keywords has-patch added

This code would reset the options, if you visit the options page or the frontend you get the default images again. Don't know where we can place this.

function update_theme_mods( $id ) {
	if ( get_header_image() || get_background_image) {
		if ( get_header_image() == wp_get_attachment_url( $id ) )
			remove_theme_mod( 'header_image' );
		elseif ( get_background_image() == wp_get_attachment_url( $id ) )
			remove_theme_mod( 'background_image' );
	}
}

add_action( 'delete_attachment', 'update_theme_mods' );

@ocean90
16 years ago

#2 @ocean90
16 years ago

After talk with nacin I have inserted it into theme.php.

#3 @nacin
16 years ago

  • Owner set to nacin
  • Status newreviewing

#4 @ryan
16 years ago

Note that this will only work for the current theme. Inactive themes pointing to deleted attachments won't be updated. I think that is acceptable.

#5 @nacin
16 years ago

  • Resolutionfixed
  • Status reviewingclosed

(In [14850]) Invalidate header/background images for the current theme when the attachment is deleted. props ocean90, fixes #12467.

Note: See TracTickets for help on using tickets.