Typecho获取文章所有图片
|
看到很多在Typecho和wordpress之间选择的文章,对于我来说,WP的生态圈无疑更丰富,但是都是PHP实现的,typecho只是有些函数没有实现而已。即: 世上本没有路 走的人多了也便成了路 我选择typecho的理由很简单,Markdown和简单 1.获取文章图片函数 function img_postthumb($content) { preg_match_all("/ $img_src = $thumbUrl[1][0]; //将赋值给img_src $img_counter = count($thumbUrl[0]); //一个src地址的计数器 if($img_counter > 0){ for($i=0;$i<$img_counter;$i++){ echo " } } } 使用 content); ?> 参考获取文章第一张图片(缩略图) 当然获取了图片,同样需要只获取内容 2.只获取内容(去除图片)使用 ~','',$this->content);?> 3.判断文章标签tags;if($tags!=null&&in_array("say",$tags[0])){ ?> ... //这个用来判断首页的说说,定义不同的样式 4.判断文章分类category == "say"): ?> ... //自带的判断分类 5.日期格式化函数 function time_tran($the_time) { $the_time=date("Y-m-d H:i:s",$the_time); $now_time = date("Y-m-d H:i:s",time()); $now_time = strtotime($now_time); $show_time = strtotime($the_time); $dur = $now_time - $show_time; if ($dur < 0) { return $the_time; } else { if ($dur < 60) { return $dur . '秒前'; } else { if ($dur < 3600) { return floor($dur / 60) . '分钟前'; } else { if ($dur < 86400) { return floor($dur / 3600) . '小时前'; } else { if ($dur < 2592000) {//3天内 return floor($dur / 86400) . '天前'; } else { return $the_time; } } } } } } 使用 date->timeStamp); ?> (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
