Merge pull request #27 from quxiaofeng/master

Choose a thumbnail from the photos of the post without a thumbnail nor a banner
This commit is contained in:
ppoffice 2015-07-06 12:12:16 +08:00
commit 1a6dd11401
1 changed files with 4 additions and 2 deletions

View File

@ -1,14 +1,16 @@
<a href="<%- url_for((post.link?post.link:post.path)) %>" class="thumbnail">
<%
var s = "";
if (post.thumbnail){
s = post.thumbnail;
}else if (post.banner){
s = post.banner;
}else if (post.photos && post.photos.length){
s = post.photos[0];
}else{
var img=/\<img\s.*?\s?src\s*=\s*['|"]?([^\s'"]+).*?\>/ig;
var result = post.content.match(img);
var result = post.content.match(img);
result = img.exec(post.content);
if(result != null) {
for(var i = result.length -1; i; --i){