EMLOG相邻文章显示缩略图代码
<?php //获取文章缩略图 function get_thum($logid){$db = MySql::getInstance();$sqlimg = "SELECT * FROM ".DB_PREFIX."attachment WHERE blogid=".$logid." AND (`filepath` LIKE '%jpg' OR `filepath` LIKE '%gif' OR `filepath` LIKE '%png') and width<=420 ORDER BY `aid` ASC LIMIT 0,1";$img = $db->query($sqlimg);while($roww = $db->fetch_array($img)){$thum_url=BLOG_URL.substr($roww['filepath'],3,strlen($roww['filepath']));}if (empty($thum_url)) {srand((double)microtime()*1000000);$randval = rand(1,10);$thum_url = TEMPLATE_URL.'rand/'.$randval.'.jpg';}return $thum_url;}?>
<?php //blog:相邻文章 function neighbor_log($neighborLog){ extract($neighborLog);?> <?php if($prevLog):?> <p><a href="<?php echo Url::log($prevLog['gid']) ?>"><img src="<?php echo get_thum($prveLog['gid']);?>" alt="<?php echo $prevLog['title'];?>" width="120" height="120" /></a></p> <?php else:?> <p>上一篇:没有了</p> <?php endif;?> <?php if($nextLog):?> <p><a href="<?php echo Url::log($nextLog['gid']) ?>"><img src="<?php echo get_thum($nextLog['gid']);?>" alt="<?php echo $nextLog['title'];?>" width="120" height="120" /></a></p> <?php else:?> <p>下一篇:没有了</p> <?php endif;?> <?php }?>
评论一下
分享本文
- 版权申明:此文如未标注转载均为本站原创,自由转载请表明出处《蓝叶博客》。
- 本文网址:https://lanyes.org/web/696.html
- 上篇文章:EMLOG内容页自动调用附件下载地址代码
- 下篇文章:网易音乐外链获取软件分享