1
ihuguowei Mar 23, 2013
我的笨方法是通过文章摘要设置。
|
2
run2 Mar 23, 2013
设置Featured Image 并显示不好么,但应该有lz想要的那种 先找Featured Image 没有的情况下读第1张图。 http://wordpress.org/extend/plugins/search.php?q=feature+image
|
3
gamecmt Mar 23, 2013
试试这个插件
WordPress图片插件 Thumbnails Anywhere |
4
foru17 Mar 23, 2013
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' ); } function get_first_image($post) { $PostContent = $post->post_content; preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $PostContent, $PostImg); $ImgNumber = count($PostImg[0]); for($i=0;$i<=$ImgNumber;$i++) { $img_src=$PostImg[1][$i]; if(img_exists($img_src)) //第一个有效图片 { if (eregi("flickr.com",$img_src)) { $img_url = str_replace(".jpg", "_s.jpg", $img_src); }else { $img_url=$img_src; $output .= '<a href="'.get_permalink($post->ID).'" title="'.wptexturize($post->post_title).'"><img src="' . $img_url . '" /></a>'; echo $output; return 1; } } } //输出默认的缩略图地址 ?> <a href="<?php the_permalink()?>"><img src="<?php bloginfo('template_url');?>/images/no-thumb.jpg" title="<?php the_title();?>" alt="<?php the_title();?>"/></a> <?php return 0; } //PHP判断远程图片是否存在 function img_exists($url) { $head=@get_headers($url); if(!is_array($head)) return false; if(file_get_contents($url,0,null,0,1)) return 1; else return 0; } } |
5
liyandong Mar 23, 2013 |
6
Sivan Mar 23, 2013
很简单,改下 function.php 开启 add_theme_support( 'post-thumbnails' );
然后在 index.php 的适当位置写入调用函数即可。 |
7
G0dBlessMe Mar 23, 2013 via iPhone
要我说就<!--more-->
|
8
ibolee Sep 3, 2013
mark~
|