0

I read through the codex for these 2 functions:

wp_get_attachment_image

http://codex.wordpress.org/Function_Reference/wp_get_attachment_image

wp_get_attachment_image_src

http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src

But when I try to run it specifying an image size it still returns the full sized image.

$image_attributes = wp_get_attachment_image_src( $post_id, 'medium' );

On the codex page under the $size definition for both functions say:

"As of Version 2.5, this parameter does not affect the size of media icons, which are always shown at their original size."

Alternatively I've tried get_the_post_thumbnail and image_downsize with no luck.

Essentially I have the $post_id for the attachment and I want to extract the url for the medium sized image.

4

2 回答 2

0

实际上我正在使用插件Automatic Featured Image Posts并在这里找到了更深入的讨论:

http://wordpress.org/support/topic/plugin-automatic-featured-image-posts-add-image-to-body-of-post-as-well-as-adding-featured-image

我试图通过插件功能将中等大小的图像源插入到我的帖子中,但最终在我的主题模板中显示中等大小的缩略图图像更容易,而不是使用:

the_post_thumbnail('medium');

谢谢回复!

于 2013-05-18T18:34:03.007 回答
0

首先获取 image_id 然后在 wp_get_attachment_image_src() 中传递参数:

$image_id = get_post_thumbnail_id( $post_id );
$image_url = wp_get_attachment_image_src($image_id,'medium'); 
于 2013-05-18T12:02:14.933 回答