#22911 closed defect (bug) (invalid)
new media dialog doesn't list custom image sizes
Reported by: | 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)
#2
@
12 years ago
Hi nacin, unfortunately I didn't got it working. I tried this in the theme's functions.php:
- 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; }
- 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
@
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 ); }
Note: See
TracTickets for help on using
tickets.
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.