WordPress获取附件元数据函数:wp_get_attachment_metadata

2022/07/13

WordPress函数wp_get_attachment_metadata用于获取附件的元数据,例如图像的宽高、缩略图版本等。

wp_get_attachment_metadata( int $attachment_id, bool $unfiltered = false )

本文涉及的内容包括:

函数参数

$attachment_id

整数

附件的ID

$unfiltered

布尔值,默认值:false

是否运行过滤器。

函数返回值

Array
(
    [width] => 768
    [height] => 430
    [file] => 2020/05/baidusrf-for-linux.webp
    [sizes] => Array
        (
            [thumbnail] => Array
                (
                    [file] => baidusrf-for-linux-320x200.jpg
                    [width] => 320
                    [height] => 200
                    [mime-type] => image/webp
                )

        )

    [image_meta] => Array
        (
            [aperture] => 0
            [credit] => 
            [camera] => 
            [caption] => 
            [created_timestamp] => 0
            [copyright] => 
            [focal_length] => 0
            [iso] => 0
            [shutter_speed] => 0
            [title] => 
            [orientation] => 0
            [keywords] => Array
                (
                )

        )

)

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注