美文网首页
emlog531从文章附件获取文章首张图片,如果没有则显示默认图

emlog531从文章附件获取文章首张图片,如果没有则显示默认图

作者: f675b1a02698 | 来源:发表于2017-09-13 08:30 被阅读0次

function getattachmentimage($logid){

$db = MySql::getInstance();

$sql = "SELECT * FROM ".DB_PREFIX."attachment WHERE blogid=".$logid." AND (`filepath` LIKE '%jpg' OR `filepath` LIKE '%gif' OR `filepath` LIKE '%png') ORDER BY `aid` ASC LIMIT 0,1";

$imgs = $db->query($sql);

$rowimg = $db->fetch_array($imgs);

if($rowimg['filepath']){

$rand_img = BLOG_URL.substr($rowimg['filepath'],3,strlen($rowimg['filepath']));

}else{

$rand_img = TEMPLATE_URL.'images/postdefimg.png';

}

return $rand_img;

}

?>

相关文章

网友评论

      本文标题:emlog531从文章附件获取文章首张图片,如果没有则显示默认图

      本文链接:https://www.haomeiwen.com/subject/psfnjxtx.html