Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#22911 closed defect (bug) (invalid)

new media dialog doesn't list custom image sizes

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

Description

When inserting an image into a post, the custom image sizes set by the theme are not listed and cannot be inserted. The theme uses set_post_thumbnail_size(...) and add_image_size(...).

Checked: The new uploader still generates the sizes, they are only not listed.

Change History (7)

#1 @nacin
12 years ago

This is not a regression, 3.4 worked the same way. If you want custom sizes to appear in the media dialog, a plugin should use the image_size_names_choose filter.

#2 @wdfee
12 years ago

Hi nacin, unfortunately I didn't got it working. I tried this in the theme's functions.php:

  1. first trial
    add_filter('image_size_names_choose', 'my_image_sizes');
    function my_image_sizes($sizes) {
            $addsizes = array(
                    "my-size" => __( "My Size")
                    );
            $newsizes = array_merge($sizes, $addsizes);
            return $newsizes;
    }
    
  1. second trial
    add_filter('image_size_names_choose', 'my_image_sizes', 11, 1);
    function my_image_sizes($sizes) {
    	$new_sizes = array();
    	$added_sizes = get_intermediate_image_sizes();
    	foreach( $added_sizes as $key => $value) {
    		$new_sizes[$value] = $value;
    	}
    	$new_sizes = array_merge( $new_sizes, $sizes );
    	return $new_sizes;
    }
    

Also tried a print_r(get_intermediate_image_sizes()); in the themes header, it's giving nothing back.

#3 @wdfee
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed

stop! got it working now. There have been a mistake in my code, it's easiest...

add_filter('image_size_names_choose', 'my_image_sizes', 11, 1);
function my_image_sizes($sizes) { 
	$new_sizes = array(  
		'my-size' => __( "My Size")  
	);  
	return array_merge( $sizes, $new_sizes );  
} 


#4 @markoheijnen
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution changed from fixed to invalid
  • Version 3.5 deleted

#5 @SergeyBiryukov
12 years ago

#22955 was marked as a duplicate.

#7 @SergeyBiryukov
10 years ago

#29393 was marked as a duplicate.

Note: See TracTickets for help on using tickets.