get_the_post_thumbnail
属性数组不知道STYLE
, 可供您使用的字段包括:
所以只需使用类并为其定义类即可:
$attr = array(
\'title\' => get_the_title(),
\'alt\' => get_the_title(),
\'class\' => \'rss_thumb\'
);
$thumb = get_the_post_thumbnail($post->ID, \'large-thumb\', $attr);
然后在类中定义样式:
<style>
.rss_thumb{float:left}
</style>
Update:
我糟糕的rss提要实际上可以设计成HTML样式,因为它不是HTML。因此,要解决这个问题,您需要将图像放在内容标签中,并为其设置align=“left”,这应该适用于大多数rss阅读器。
因此,您真正想要的是添加content\\u筛选器:
add_filter(\'the_content\',\'add_rss_thumb\');
function add_rss_thumb($content){
if (!is_feed()){
return $content;
}
//now that we know is a feed we add the image to the content:
global $post;
if(has_post_thumbnail()) {
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
$thumbnail_attributes = wp_get_attachment_image_src( $post_thumbnail_id );
/*
$thumbnail_attributes is an array containing:
[0] => url
[1] => width
[2] => height
*/
return \'<img src="\'.thumbnail_attributes[0].\'" title="\'.the_title_attribute(\'\',\'\',0).\'" alt="\'.the_title_attribute(\'\',\'\',0).\'" align="left">\'.$content;
}
return $content;
}