WordPress为JS准备附件对象函数:wp_prepare_attachment_for_js

本站正在使用的主机

本站目前托管于腾讯云香港轻量服务器,价格便宜访问速度也快,使用本站推荐链接购买还可免费获得WordPress运行环境优化服务。

最新活动 »

WordPress函数wp_prepare_attachment_for_js为JS准备附件对象,包含了附件的所有信息。

wp_prepare_attachment_for_js( int|WP_Post $attachment )

函数参数

$attachment

整数或WP_Post对象

附件的ID或对象

函数返回值

Array
(
    [id] => 3163
    [title] => baidusrf-for-linux
    [filename] => baidusrf-for-linux.webp
    [url] => https://www.beizigen.com/wp-content/uploads/2020/05/baidusrf-for-linux.webp
    [link] => https://www.beizigen.com/2895.html/baidusrf-for-linux
    [alt] => 替代文本
    [author] => 1
    [description] => 
     => 百度输入法Linux版
    [name] => baidusrf-for-linux
    [status] => inherit
    [uploadedTo] => 2895 //父ID
    [date] => 1601856000
    [modified] => 1601856000
    [menuOrder] => 0
    [mime] => image/webp
    [type] => image
    [subtype] => webp
    [icon] => https://www.beizigen.com/wp-includes/images/media/default.png
    [dateFormatted] => 2020年10月05日
    [nonces] => Array
        (
            [update] => 
            [delete] => 
            [edit] => 
        )

    [editLink] => 
    [meta] => 
    [authorName] => admin
    [authorLink] => 
    [uploadedToTitle] => 百度输入法Linux版
    [uploadedToLink] => 
    [filesizeInBytes] => 22528
    [filesizeHumanReadable] => 22 KB
    [context] => 
    [height] => 430
    [width] => 768
    [orientation] => landscape
    [sizes] => Array
        (
            [thumbnail] => Array
                (
                    [height] => 200
                    [width] => 320
                    [url] => https://www.beizigen.com/wp-content/uploads/2020/05/baidusrf-for-linux-320x200.webp
                    [orientation] => landscape
                )

            [full] => Array
                (
                    [url] => https://www.beizigen.com/wp-content/uploads/2020/05/baidusrf-for-linux.webp
                    [height] => 430
                    [width] => 768
                    [orientation] => landscape
                )

        )

)

扩展阅读

wp_prepare_attachment_for_js()函数位于:wp-includes/media.php

相关函数:

  • get_media_states()
  • wp_get_original_image_url()
  • wp_get_original_image_path()
  • wp_ajax_media_create_image_subsizes()
  • wp_ajax_crop_image()
  • wp_ajax_upload_attachment()
  • wp_ajax_get_attachment()
背字根微信二维码

本站文章均为原创,码字非常不容易,转载请注明原文出处,给苦逼的作者保留一点创作动力。