最新公告
  • 欢迎您光临知事网软件APP资源下载站,一个优质的手机App应用商店和网站源码基地。欢迎加入永久SVIP
  • WordPress函数wp_get_attachment_thumb_file()用法 获取附件缩略图(特色图像)文件路径

    正文概述 知事网   2020-09-17 09:09:37   547

    描述:

    返回附件的缩略图(特色图像)文件路径

    用法:

    <?php wp_get_attachment_thumb_file( $attachment_id ); ?>
    

    参数:

    $attachment_id
    
    (integer) (可选) 附件ID
    
    默认值: 0

    源文件:

    $attachment_id
    
    (integer) (可选) 附件ID
    
    默认值: 0/**
    * Retrieve thumbnail for an attachment.
    *
    * @since 2.1.0
    *
    * @param int $post_id Optional. Attachment ID. Default 0.
    * @return string|false False on failure. Thumbnail file path on success.
    */
    function wp_get_attachment_thumb_file( $post_id = 0 ) {
    $post_id = (int) $post_id;
    if ( !$post = get_post( $post_id ) )
    return false;
    if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )
    return false;
    
    $file = get_attached_file( $post->ID );
    
    if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) {
    /**
    * Filter the attachment thumbnail file path.
    *
    * @since 2.1.0
    *
    * @param string $thumbfile File path to the attachment thumbnail.
    * @param int $post_id Attachment ID.
    */
    return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
    }
    return false;
    }

    知事网 » WordPress函数wp_get_attachment_thumb_file()用法 获取附件缩略图(特色图像)文件路径

    发表评论

    还没有评论,快来抢沙发吧!

    [!--temp.right--]
    请选择支付方式
    ×
    余额支付
    ×
    微信扫码支付 0 元