您的当前位置:首页 > 知识博客 > wordpress建站

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

时间:2024-03-12

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
                (
                )

        )

)

扩展阅读

wp_get_attachment_metadata()函数位于:wp-includes/post.php

相关函数:

  • get_post_meta()

  • wp_get_attachment_image_src()

  • wp_get_attachment_image_url()

  • wp_get_attachment_image_sizes()

  • wp_get_attachment_image_srcset()

  • wp_get_attachment_image_attributes()


欢迎咨询/Welcome to inquire
tel/vx:18842938855
qq:1685522781
email:1685522781@qq.com

Copyright © 2019-2024 19.org.cn


Whatsapp