A WordPress-centric search engine for devs and theme authors



_wp_get_image_size_from_meta ›

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 valid image size name ('thumbnail', 'medium', etc.).
    Required: Yes
  • (array) $image_meta The image meta data.
    Required: Yes
Returns:
  • (array|bool) Array of width and height values in pixels (in that order) or false if the size doesn't exist.
Defined at:
Codex:

Get 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 ( $size_name === 'full' ) {
		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;
}