[wp-trac] [WordPress Trac] #48003: Function wp_prepare_attachment_for_js() missing other sizes
WordPress Trac
noreply at wordpress.org
Sun Oct 6 08:02:16 UTC 2019
#48003: Function wp_prepare_attachment_for_js() missing other sizes
--------------------------+------------------------------
Reporter: kkatusic | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 5.2.3
Severity: minor | Resolution:
Keywords: needs-patch | Focuses:
--------------------------+------------------------------
Comment (by iCaleb):
Hmm, I'm struggling to replicate any differences with recent versions. Do
you recall which version of WordPress you were on previously?
According to [the
code](https://github.com/WordPress/WordPress/blob/ecf00fc84407249ae2a699e3b3d31571194efa34
/wp-includes/media.php#L3462-L3478), everything works correctly for me.
For example, if I have the following in my theme:
{{{#!php=
add_filter( 'image_size_names_choose', 'custom_image_size_names_48003' );
function custom_image_size_names_48003( $sizes ) {
return array_merge( $sizes, array(
'my-custom-size' => __( 'My Custom Size' ),
) );
}
add_action( 'after_setup_theme', 'add_custom_image_sizes_48003' );
function add_custom_image_sizes_48003() {
add_image_size( 'my-custom-size', 220, 180, true );
add_image_size( 'some-other-size', 300 );
}
}}}
Then `wp_prepare_attachment_for_js()` for a newly uploaded image will
return `'sizes' => array(4) { 'thumbnail', 'medium', 'vip-custom-size',
'full' }`.
Note that only the custom image size that I gave a display name shows up.
More info:
https://developer.wordpress.org/reference/functions/add_image_size/#for-
media-library-images-admin
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48003#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list