Make WordPress Core

Opened 14 years ago

Closed 11 years ago

Last modified 11 years ago

#16203 closed defect (bug) (duplicate)

Modifications of media doesn't generate alternatives added by add_image_size()

Reported by: andreaswedberg's profile andreaswedberg Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.4
Component: Media Keywords:
Focuses: Cc:

Description

Upload an image, then select "Edit Image".
Crop the image and Save.
Images with sizes added eith add_image_size() doesn't get alternatives generated as the standard sizes does.

Change History (3)

#1 @aut0poietic
13 years ago

Just to add more information here: add_image_size() only temporarily adds the image size to the $_wp_additional_image_sizes array ( in wp-includes/media.php ).

The admin panel does not use this array, and instead uses the options "{$size}_crop", "{$size}_size_w" and "{$size}_size_h" ( line 633 & 644 of wp-admin/includes/image-edit.php ). If those options don't exist, the theme/plugin added image size will not be updated.

I've worked around the issue by calling add_option() for these option names at the same time I add the image size:

if ( function_exists( 'add_theme_support' ) ) 
{ 
	add_theme_support( 'post-thumbnails' ) ; 
	add_image_size( 'my-custom-thumb', 478, 478, true );

	// add_image_size() edit patch
	add_option( 'my-custom-thumb_crop' , true  , '' , 'yes' ) ;
	add_option( 'my-custom-thumb_size_w' , 478 , '' , 'yes' ) ;
	add_option( 'my-custom-thumb_size_h' , 478 , '' , 'yes' ) ;
}

I'm not sure what the repercussions would be if similar code was added to add_image_size().

#2 @markoheijnen
11 years ago

  • Keywords add_image_size removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

More discussion on #19889 about this.

#3 @SergeyBiryukov
11 years ago

To clarify, #17475 attempted to fix this, but the fix was incomplete.

Note: See TracTickets for help on using tickets.