wp_get_attachment_image_sizes
函数
wp_get_attachment_image_sizes ( $attachment_id, $size = 'medium', $image_meta = null )
- 参数
-
-
(int)
$attachment_id
Image attachment ID.- Required: 是
-
(string|int[])
$size
Optional. Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order). Default ‘medium’.- Required: 否
- Default: ‘medium’
-
(array)
$image_meta
Optional. The image meta data as returned by ‘wp_get_attachment_metadata()’. Default null.- Required: 否
- Default: null
-
(int)
- 返回值
-
- (string|false) A valid source size value for use in a ‘sizes’ attribute or false.
- 相关
-
- wp_calculate_image_sizes()
- 定义位置
-
-
wp-includes/media.php
, line 1453
-
wp-includes/media.php
- 引入
- 4.4.0
- 弃用
- –
检索图片附件的 “sizes”属性的值。
function wp_get_attachment_image_sizes( $attachment_id, $size = 'medium', $image_meta = null ) { $image = wp_get_attachment_image_src( $attachment_id, $size ); if ( ! $image ) { return false; } if ( ! is_array( $image_meta ) ) { $image_meta = wp_get_attachment_metadata( $attachment_id ); } $image_src = $image[0]; $size_array = array( absint( $image[1] ), absint( $image[2] ), ); return wp_calculate_image_sizes( $size_array, $image_src, $image_meta, $attachment_id ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。