wp_get_attachment_metadata 获取多媒体附件的元信息

Posted in:
Update time:2020-10-29

函数描述

获取指定 ID 的附件元信息字段。

Usage

<?php wp_get_attachment_metadata( $attachment_id, $unfiltered ); ?>

parameters

parametersdata typeRequired or notdescriptivedefault value
$attachment_idinteger (math.)be附件 IDnot have
$unfiltered布尔值clogged如果为 true, 不运行 filtersfalse

return value

数组或布尔值,附件元数据字段,获取失败,返回 False,元数据字段有:

  • width (integer) 附件宽度
  • height (integer) 附件高度
  • file (string) 附件相对于 `wp-content/uploads/` 的路径
  • sizes (array) 附件尺寸名称,每个数组包括 ‘file’, ‘width’, ‘height’, and ‘mime-type’ image_meta (array)

返回示例

Array
   (
       [width] => 2400
       [height] => 1559
       [file] => 2011/12/press_image.jpg
       [sizes] => Array
           (
               [thumbnail] => Array
                   (
                       [file] => press_image-150x150.jpg
                       [width] => 150
                       [height] => 150
                       [mime-type] => image/jpeg
                   )
               [medium] => Array
                   (
                       [file] => press_image-4-300x194.jpg
                       [width] => 300
                       [height] => 194
                       [mime-type] => image/jpeg
                   )
               [large] => Array
                   (
                       [file] => press_image-1024x665.jpg
                       [width] => 1024
                       [height] => 665
                       [mime-type] => image/jpeg
                   )
               [post-thumbnail] => Array
                   (
                       [file] => press_image-624x405.jpg
                       [width] => 624
                       [height] => 405
                       [mime-type] => image/jpeg
                   )
           )
       [image_meta] => Array
           (
               [aperture] => 5
               [credit] => 
               [camera] => Canon EOS-1Ds Mark III
                => 
               [created_timestamp] => 1323190643
               [copyright] => 
               [focal_length] => 35
               [iso] => 800
               [shutter_speed] => 0.016666666666667
               [title] => 
           )
   )

We offer WordPress Themes and Plugins Custom Development Services

This site has long undertaken WordPress themes, plugins, WooCommerce-based store mall development business. We have 10 years of experience in WordPress development, if you want to Developing Websites with WordPress, please contact WeChat: iwillhappy1314 or email: amos@wpcio.com for inquiries.

发表回复

Your email address will not be published. 必填项已用 * 标注

*