WordPress at Your Fingertips

wp_get_additional_image_sizes() WP 4.7.0

Gets data of all additionally registered image sizes (thumbnails).

By default WordPress has four image sizes: thumbnail, medium, medium_large, large. Using add_image_size() function, You can add additional image sizes. Now, to get all these extra sizes, you can use this function.

  • Uses global variable $_wp_additional_image_sizes.
1 time — 0.000024 sec (very fast) | 50000 times — 0.01 sec (speed of light) | PHP 7.1.5, WP 4.8.2

No Hooks.

Return

Array. Additional images size data.

Usage

wp_get_additional_image_sizes();

Examples

#1 Get additional image sizes

We will get such array if to use this function for twentyfifteen theme that has one additional image size: post-thumbnail.

print_r( wp_get_additional_image_sizes() );

/* Output
Array(
	[post-thumbnail] => Array(
		[width]  => 825
		[height] => 510
		[crop]   => 1
	)
)
*/

Notes

  • Global. Array. $_wp_additional_image_sizes

Changelog

Since 4.7.0 Introduced.

Code of wp_get_additional_image_sizes() WP 5.8.1

function wp_get_additional_image_sizes() {
	global $_wp_additional_image_sizes;

	if ( ! $_wp_additional_image_sizes ) {
		$_wp_additional_image_sizes = array();
	}

	return $_wp_additional_image_sizes;
}

image (not thumbnails funcs)

Thumbnails

vladlu 100vlad.lu
Editors: Kama 101
No comments
    Log In