dux
fuction.php添加
//输出缩略图地址
function post_thumbnail_img($width,$height) {
global $post;
$title = $post->post_title;
if (get_option('template')=='dux'){
if ( has_post_thumbnail() ) {
$timthumb_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID) , 'full');
$post_timthumb = '<img src="' . get_bloginfo("template_url") . '/timthumb.php?src=' . $timthumb_src[0] . '&h=' . $height . '&w=' . $width . '&zc=1" width="'.$width.'" height="'.$height.'" alt="' . $title . '" />';
echo $post_timthumb;
} else {
$content = $post->post_content;
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
echo '<img src="' . get_bloginfo("template_url").'/timthumb.php?src=' . $strResult[1][0] . '&h=' . $height . '&w=' . $width . '&zc=1" width="'.$width.'" height="'.$height.'" alt="'.$title.'" />';
}else {
echo '<img src="' . get_bloginfo("template_url").'/images/noimage.gif" width="'.$width.'" height="'.$height.'" alt="暂无图片">';
}
}
}else{
if ( has_post_thumbnail() ) {
the_post_thumbnail(array($width,$height));
} else {
$content = $post->post_content;
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
echo '<img src="'.$strResult[1][0].'" width="'. $width .'" height="'.$height.'" alt="'.$title.'"/>';
}else {
echo '<img src="' . get_bloginfo("template_url").'/images/noimage.gif" width="'.$width.'" height="'.$height.'" alt="暂无图片">';
}
}
}
}
//列表图片
function post_thumbnail_list($width=220) {
global $post;
$title = $post->post_title;
if (get_option('template')=='dux'){
if ( has_post_thumbnail() ) {
$timthumb_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID) , 'full');
$post_timthumb = '<img src="' . get_bloginfo("template_url") . '/timthumb.php?src=' . $timthumb_src[0] . '&w=' . $width . '&zc=1;a=t" alt="' . $title . '" />';
echo $post_timthumb;
} else {
$content = $post->post_content;
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
echo '<img src="' . get_bloginfo("template_url").'/timthumb.php?src=' . $strResult[1][0] . '&h=150&w=' . $width . '&zc=1" alt="'.$title.'" class="thumb" />';
}
}
}else{
if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else {
$content = $post->post_content;
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
echo '<img src="'.$strResult[1][0].'" width="'. $width .'" height="auto" alt="'.$title.'"/>';
}
}
}
}
在主题下放入timthumb.php,新建文件夹cache,权限755
修改excerpt.php中
echo ‘<a’._post_target_blank().’ class=”focus” href=”‘.get_permalink().'”>’.$_thumb.'</a>’;
为
echo ‘<a’._post_target_blank().’ class=”focus” href=”‘.get_permalink().'”>’;
echo ‘<?php echo ‘.post_thumbnail_list().’?>’;
echo ‘</a>’;
修改mo_posts_related.php中
if( $thumb_s ) echo ‘<a href=”‘.get_permalink().'”>’._get_post_thumbnail().'</a>’;
为
if( $thumb_s ) echo ‘<a href=”‘.get_permalink().'”>’.post_thumbnail_list().'</a>’;
修改widget-posts.php中
echo $pic;
为
echo ‘<?php echo ‘.post_thumbnail_list().’?>’;
xiu主题
fuction.php添加
//输出缩略图地址
function post_thumbnail_img($width,$height) {
global $post;
$title = $post->post_title;
if (get_option('template')=='xiu'){
if ( has_post_thumbnail() ) {
$timthumb_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID) , 'full');
$post_timthumb = '<img src="' . get_bloginfo("template_url") . '/timthumb.php?src=' . $timthumb_src[0] . '&h=' . $height . '&w=' . $width . '&zc=1" width="'.$width.'" height="'.$height.'" alt="' . $title . '" />';
echo $post_timthumb;
} else {
$content = $post->post_content;
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
echo '<img src="' . get_bloginfo("template_url").'/timthumb.php?src=' . $strResult[1][0] . '&h=' . $height . '&w=' . $width . '&zc=1" width="'.$width.'" height="'.$height.'" alt="'.$title.'" />';
}else {
echo '<img src="' . get_bloginfo("template_url").'/images/noimage.gif" width="'.$width.'" height="'.$height.'" alt="暂无图片">';
}
}
}else{
if ( has_post_thumbnail() ) {
the_post_thumbnail(array($width,$height));
} else {
$content = $post->post_content;
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
echo '<img src="'.$strResult[1][0].'" width="'. $width .'" height="'.$height.'" alt="'.$title.'"/>';
}else {
echo '<img src="' . get_bloginfo("template_url").'/images/noimage.gif" width="'.$width.'" height="'.$height.'" alt="暂无图片">';
}
}
}
}
//列表图片
function post_thumbnail_list($width=240) {
global $post;
$title = $post->post_title;
if (get_option('template')=='xiu'){
if ( has_post_thumbnail() ) {
$timthumb_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID) , 'full');
$post_timthumb = '<img src="' . get_bloginfo("template_url") . '/timthumb.php?src=' . $timthumb_src[0] . '&w=' . $width . '&zc=1;a=t" alt="' . $title . '" />';
echo $post_timthumb;
} else {
$content = $post->post_content;
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
echo '<img src="' . get_bloginfo("template_url").'/timthumb.php?src=' . $strResult[1][0] . '&h=180&w=' . $width . '&zc=1" alt="'.$title.'" class="thumb" />';
}
}
}else{
if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else {
$content = $post->post_content;
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
echo '<img src="'.$strResult[1][0].'" width="'. $width .'" height="auto" alt="'.$title.'"/>';
}
}
}
}
在主题下放入timthumb.php,新建文件夹cache,权限755
修改excerpt.php中
‘</p>’,
$focuscode,
‘<p class=”note”>’.hui_get_excerpt_content().'</p>’,
为
‘</p>’;
echo ‘<a’.hui_target_blank().’ class=”focus” href=”‘.$plink.'”>’;
echo ‘<?php echo ‘.post_thumbnail_list().’?>’;
echo ‘</a>’;
echo ‘<p class=”note”>’.hui_get_excerpt_content().'</p>’,
修改functions.xiu.php中
echo hui_get_thumbnail();
为
echo post_thumbnail_list();
修改widget-postlist.php中
echo ‘<span class=”thumbnail”>’.hui_get_thumbnail().'</span>’;
为
echo ‘<span class=”thumbnail”>’; echo ‘<?php echo ‘.post_thumbnail_list().’?>’; echo ‘</span>’;
justnews
修改fuctions.php,添加cache,修改post-thumb.php,loop-default.php