Alert: 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.

_wp_get_image_size_from_meta() WordPress Function

The _wp_get_image_size_from_meta() function is used to get the image size from meta data. This function can be used to get the image size from an attachment ID or from a file path.

_wp_get_image_size_from_meta( string $size_name, array $image_meta ) #

Get the image size as array from its meta data.


Description

Used for responsive images.


Top ↑

Parameters

$size_name

(string)(Required)Image size. Accepts any registered image size name.

$image_meta

(array)(Required)The image meta data.


Top ↑

Return

(array|false) Array of width and height or false if the size isn't present in the meta data.

  • (int) Image width.
  • '1'
    (int) Image height.


Top ↑

Source

File: wp-includes/media.php

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;
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More