wpseek.com
A WordPress-centric search engine for devs and theme authors



_wp_get_image_size_from_meta › WordPress Function

Since4.4.0
Deprecatedn/a
_wp_get_image_size_from_meta ( $size_name, $image_meta )
Access:
  • private
Parameters: (2)
  • (string) $size_name Image size. Accepts any registered image size name.
    Required: Yes
  • (array) $image_meta The image meta data.
    Required: Yes
Returns:
  • (array|false) { Array of width and height or false if the size isn't present in the meta data. @type int $0 Image width. @type int $1 Image height. }
Defined at:
Codex:

Gets the image size as array from its meta data.

Used for responsive images.


Source

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