apply_filters( 'image_size_names_choose', string[] $size_names )

Filters the names and labels of the default image sizes.


Parameters Parameters

$size_names

(string[]) Array of image size labels keyed by their name. Default values include 'Thumbnail', 'Medium', 'Large', and 'Full Size'.


Top ↑

More Information 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.


Top ↑

Source Source

File: wp-admin/includes/media.php

View on Trac



Top ↑

Changelog Changelog

Changelog
Version Description
3.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Rami Yushuvaev

    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 2 content
    Contributed by stevenlinx

    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.