From 9ca2ed1133c05770b3b687e57f375d22a4892046 Mon Sep 17 00:00:00 2001 From: Xiaofeng QU Date: Mon, 6 Jul 2015 11:54:55 +0800 Subject: [PATCH] Choose a thumbnail from the photos of the post without thumbnail and banner Signed-off-by: Xiaofeng QU --- layout/_partial/post/thumbnail.ejs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/layout/_partial/post/thumbnail.ejs b/layout/_partial/post/thumbnail.ejs index 8682885..b53b0e4 100644 --- a/layout/_partial/post/thumbnail.ejs +++ b/layout/_partial/post/thumbnail.ejs @@ -1,14 +1,16 @@ <% 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=/\/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){