_wp_get_image_size_from_meta

函数
_wp_get_image_size_from_meta ( $size_name, $image_meta )
Access
Private
参数
  • (string) $size_name Image size. Accepts any registered image size name.
    Required:
  • (array) $image_meta The image meta data.
    Required:
返回值
  • (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. }
定义位置
相关方法
wp_get_image_mimewp_getimagesizewp_get_image_editorwp_create_image_subsizesget_date_from_gmt
引入
4.4.0
弃用
-

_wp_get_image_size_from_meta: 这个函数用于获取特定图像的图像尺寸元数据。它接收一个图像ID,并返回一个包含图像尺寸元数据的数组。

从元数据中获取图片大小的数组。用于响应式图像。

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

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-14 12:36:31

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: