[织梦教程] 织梦首页调用图集第一张大图的两种方法

[复制链接]
查看2570 | 回复7 | 2020-4-11 04:02:07 | 显示全部楼层 |阅读模式

第一种方法:(推荐)
首先在include/extend.func.php下添加函数:

1
2
3
4
5
6
7
8
function  get_firstbigimg( $arcid ){ 
   //获取图片附加表imgurls字段内容进行处理 
   global  $dsql
    $row  $dsql ->GetOne( "Select imgurls From genban_addonimages where aid='$arcid'" );
     preg_match_all( "|height='.*'}(.*){/dede:img}|Uis" , $row [ 'imgurls' ], $imgurls );  //获取所有图片地址
     $get_firestimg  $imgurls [1][0];  // 
     return  $get_firestimg
}

然后修改include/taglib/arclist.lib.php 
在513行添加

1
$row [ 'first_imgurl' ] = get_firstbigimg( $row [ 'id' ]);

到这里就全部修改好了,调用的方法:

1
2
3
{dede:arclist row= 3  orderby=pubdate typeid= '17'  type= 'image.' titlelen= '60' }
<div  class = "pic" ><a href= "[field:arcurl/]"  target= "_blank" ><img src=[field:first_imgurl/] /><br />[field:title/]</a></div>
{/dede:arclist}

第二种方法:

步骤一:
修改include/extend.func.php

添加如下代码:

//取第一张图地址
function firstimg($str_pic)
{
$str_sub=substr($str_pic,0,-7).".jpg";//删除缩略图字符串最后七位,然后再补上后缀.jpg
return $str_sub;
}
步骤二:直接在dede模板里面写调用标签

然后在模板里循环调用:

在列表使用:[field:litpic function=firstimg('@me')/]
在内容页使用:{dede:field name='litpic' function="firstimg(@me)"/}

 该修改方法有一个缺点:就是上传的图片必须是jpg格式的,定死格式了有点麻烦。

从0基础开始学习织梦dedecms建站,分享全套的织梦dedecms网站搭建教程、织梦安装使用教程。 汇聚了最全、最新的织梦cms建站教程。包含dedecms建站、仿站教程;dedecms系统使用常见问题;主题插件推荐下载等!欢迎学习!
回复

使用道具 举报

潘多拉945 | 2020-12-28 19:39:36 | 显示全部楼层
资源太多了,准备办个会员
回复

使用道具 举报

123457439 | 2021-2-12 01:08:08 | 显示全部楼层
我是来白嫖悟空源码的资源的!
回复

使用道具 举报

蓝毛凤凰都bv | 2021-6-3 21:43:18 | 显示全部楼层
支持悟空源码,越来越好
回复

使用道具 举报

veronica六 | 2021-6-17 19:31:19 | 显示全部楼层
很不错的资源站
回复

使用道具 举报

上帝从不眨眼 | 2021-9-4 14:46:41 | 显示全部楼层
祝愿悟空源码越办越好!
回复

使用道具 举报

123457865 | 2022-4-5 17:46:52 | 显示全部楼层
这个下载站资源真齐全
回复

使用道具 举报

啤酒瓶空了缓 | 2022-6-1 05:53:33 | 显示全部楼层
站长真良心,这么大的资源站都是免费下载
回复

使用道具 举报

幸福教主浦 | 2023-1-19 20:04:20 | 显示全部楼层
悟空源码太厉害,资源真多!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则