image_size_names_choose

最后更新于:2021-11-27 01:00:49

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

Filters the names and labels of the default image sizes.

参数

$size_names

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

源文件

文件: gc-admin/includes/media.php

View on Trac

// 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 GeChiUI admin.
function custom_image_sizes( $size_names ) {
	$new_sizes = array(
		'custom-size-1' => __( 'Custom Size #1', 'generategc.com' ),
		'custom-size-2' => __( 'Custom Size #2', 'generategc.com' ),
	);
	return array_merge( $size_names, $new_sizes );
}
add_filter( 'image_size_names_choose', 'custom_image_sizes' );