function vide_the_thumbnail() { global $post; // 判断该文章是否设置的缩略图,如果有则直接显示 if (has_post_thumbnail()) { the_post_thumbnail('largevideo'); } else { //没有就显示系统的视频图片 $content = $post->post_content; $imgurl = videclass::parseimgurl($content); if ($imgurl) { echo "<img src=" . $imgurl . " width = '230' height='173' />"; } } }
?> "><?php // 判断该文章是否设置的缩略图,如果有则直接显示 if (has_post_thumbnail()) { the_post_thumbnail('medium', array('alt' => trim(strip_tags($post->post_title)), 'title' => trim(strip_tags($post->post_title)))); } 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 '<a href="' . get_permalink() . '"><img src="' . $strResult[1][0] . '" width = "140" height="100"/></a>'; } else { // 如果文章内没有图片,则用判断是否为视频。 $imgurl = videclass::parseimgurl($content); if ($imgurl) { echo "<a href=" . get_permalink() . "><img src=" . $imgurl . " width = '140' height='100' /></a>"; } else { //如果不是视频内容则自动匹配默认缩略图 $random = mt_rand(1, 20); echo '<a href="' . get_permalink() . '"><img src="' . get_bloginfo('stylesheet_directory') . '/images/random/tb' . $random . '.jpg" /></a>'; } } } ?> </a></div></div> <div class="entry_post"> <span><?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 240, "...", "utf-8"); ?>
$tags = wp_get_post_tags($post->ID); $tagIDs = array(); $a = 0; if ($tags) { $tagcount = count($tags); for ($i = 0; $i < $tagcount; $i++) { $tagIDs[$i] = $tags[$i]->term_id; } $args = array('tag__in' => $tagIDs, 'post__not_in' => array($post->ID), 'showposts' => 6, 'cat' => $ids, 'caller_get_posts' => 1); $my_query = new WP_Query($args); if ($my_query->have_posts()) { while ($my_query->have_posts()) { $my_query->the_post(); $content = $post->post_content; //文档内容 $info = videclass::parseinfo($content); ?> <li> <a class="video_thumb" href="<?php the_permalink(); ?> "> <?php if (has_post_thumbnail()) { the_post_thumbnail('largevideo'); } else { ?> <img src="<?php echo $info['img']; ?> ">