On this page
_wp_get_image_size_from_meta( string $size_name, array $image_meta ): array|false
This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Gets the image size as array from its meta data.
Description
Used for responsive images.
Parameters
$size_namestring Required-
Image size. Accepts any registered image size name.
$image_metaarray Required-
The image meta data.
Return
array|false Array of width and height or false if the size isn't present in the meta data.
- int
Image width.
1intImage height.
Source
File: wp-includes/media.php. View all references
function _wp_get_image_size_from_meta( $size_name, $image_meta ) {
if ( 'full' === $size_name ) {
return array(
absint( $image_meta['width'] ),
absint( $image_meta['height'] ),
);
} elseif ( ! empty( $image_meta['sizes'][ $size_name ] ) ) {
return array(
absint( $image_meta['sizes'][ $size_name ]['width'] ),
absint( $image_meta['sizes'][ $size_name ]['height'] ),
);
}
return false;
}
Related
Uses
| Uses | Description |
|---|---|
| absint() wp-includes/functions.php | Converts a value to non-negative integer. |
Used By
| Used By | Description |
|---|---|
| WP_Widget_Media_Image::render_media() wp-includes/widgets/class-wp-widget-media-image.php | Render the media on the frontend. |
| wp_calculate_image_sizes() wp-includes/media.php | Creates a ‘sizes’ attribute value for an image. |
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_wp_get_image_size_from_meta