php Wordpress附件图像

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Wordpress附件图像相关的知识,希望对你有一定的参考价值。

<?php
$attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image') );
foreach ( $attachments as $attachment_id => $attachment ) {
    echo '<p>';
    echo 'wp_get_attachment_image: ' . wp_get_attachment_image( $attachment_id, array(200,250) ) . '<br />';
    echo 'wp_get_attachment_link: ' . wp_get_attachment_link( $attachment_id ) . '<br />';
    echo 'wp_get_attachment_url: ' . wp_get_attachment_url( $attachment_id ) . '<br />';
    echo 'wp_get_attachment_thumb_url: ' . wp_get_attachment_thumb_url( $attachment_id ) . '<br />';
    echo 'get_attachment_link: ' . get_attachment_link( $attachment_id ) . '<br />';
    $src = image_get_intermediate_size( $attachment_id, 'medium'     );
    echo 'image_get_intermediate_size. '; var_dump($src); echo '<br />';
    $src = wp_get_attachment_image_src( $attachment_id, 'full', true );
    echo 'wp_get_attachment_image_src. '; var_dump($src); echo '<br />';
    echo 'Title of attachment: ' . apply_filters( 'the_title', $attachment->post_title ) . '<br />';
    echo 'Link to post: ' . get_permalink($image->post_parent) . '<br />';
    echo '<hr style="clear:both;" /></p>';
} ?>

以上是关于php Wordpress附件图像的主要内容,如果未能解决你的问题,请参考以下文章

PHP Wordpress附件图像

PHP 显示WordPress帖子的第一个图像附件

php 从其URL获取图像的WordPress附件ID

php 从其URL获取图像的WordPress附件ID

PHP 使用帖子附件的Wordpress图像库短代码

PHP 获取wordpress图像附件并使用tim thumb进行裁剪