<ul class="swiper-wrapper">
{module module=news flag=1 num=3}
<li class="swiper-slide">
<a href="{$t.url}" target="_blank">
<img src="{dr_get_file($t.thumb)}" alt="{$t.title}">
</a>
<h3 class="slide-title">
<a href="{$t.url}" target="_blank">{$t.title}</a>
</h3>
</li>
{/module}
</ul>其中flag指定推荐位ID号,缩略图原图调用方式使用de_get_file函数,如果需要裁切图片可以使用dr_thumb($t.thumb,200,200),
更多dr_thumb函数使用方法查看如下:
// 缩略图
function dr_thumb($img, $width = 200, $height = 200, $water = 0, $mode = 'auto') {
if (is_numeric($img)) {
list($cache_path, $cache_url) = dr_thumb_path();
// 图片缩略图文件
$cache_file = md5($img).'/'.$width.'x'.$height.($water ? '_water' : '').'_'.$mode.'.jpg';
if (is_file($cache_path.$cache_file)) {
return $cache_url.$cache_file;
}
return \Phpcmf\Service::L('image')->thumb($img, $width, $height, $water, $mode);
}
$file = dr_file($img);
return $file ? $file : ROOT_THEME_PATH.'assets/images/nopic.gif';
}参考:https://www.xunruicms.com/doc/898.html
如果本文对你有帮助,欢迎打赏本站

支付宝扫码打赏
微信扫码打赏
