apply_filters( ‘image_size_names_choose’, string[] $size_names )

Filters the names and labels of the default image sizes.

Parameters

$size_namesstring[]
Array of image size labels keyed by their name. Default values include 'Thumbnail', 'Medium', 'Large', and ‘Full Size’.

More Information

The ‘image_size_names_choose‘ filter allows modification of the list of image sizes that are available to administrators in the WordPress Media Library.

This is most commonly used to make custom image sizes available from selection in the WordPress admin.

Source

$size_names = apply_filters(
	'image_size_names_choose',
	array(
		'thumbnail' => __( 'Thumbnail' ),
		'medium'    => __( 'Medium' ),
		'large'     => __( 'Large' ),
		'full'      => __( 'Full Size' ),
	)
);

Changelog

VersionDescription
3.3.0Introduced.

User Contributed Notes

  1. Skip to note 3 content

    Add a new image sizes to the Media Library .

    // Add images sizes.
    function custom_theme_setup() {
    	add_image_size( 'custom-size-1', 1200, 300, true );
    	add_image_size( 'custom-size-2', 1000, 333, true );
    }
    add_action( 'after_setup_theme', 'custom_theme_setup' );
    
    // Make custom sizes selectable from WordPress admin.
    function custom_image_sizes( $size_names ) {
    	$new_sizes = array(
    		'custom-size-1' => __( 'Custom Size #1', 'generatewp.com' ),
    		'custom-size-2' => __( 'Custom Size #2', 'generatewp.com' ),
    	);
    	return array_merge( $size_names, $new_sizes );
    }
    add_filter( 'image_size_names_choose', 'custom_image_sizes' );
  2. Skip to note 4 content

    Example migrated from Codex:

    The following will add a new image size option to the list of selectable sizes in the Media Library.

    add_filter( 'image_size_names_choose', 'my_custom_sizes' );
    
    function my_custom_sizes( $sizes ) {
        return array_merge( $sizes, array(
            'your-custom-size' => __('Your Custom Size Name'),
        ) );
    }

You must log in before being able to contribute a note or feedback.