• phpcms v9 调用自定义字段多图片的第一张或第N张图为缩略图


    1.打开相应要使用组图的模型的组图字段,添加组图 字段提示为

    1 <div class="content_attr"> 
    2 <label><input type='checkbox' name='auto_thumbp' value="1" checked>是否获取内容第</label><input type="text" name="auto_thumb_nop" value="1" size="2" class="">张图片作为标题图片 
    3 </div> 

    2.打开phpcmsmodelcontent_model.class.php 找到如下内容

    1 //自动提取缩略图 
    2 if(isset($_POST['auto_thumb']) && $systeminfo['thumb'] == '' && isset($modelinfo['content'])) { 
    3  $content = $content ? $content : stripslashes($modelinfo['content']); 
    4  $auto_thumb_no = intval($_POST['auto_thumb_no'])-1; 
    5  if(preg_match_all("/(src)=(["|']?)([^ "'>]+.(gif|jpg|jpeg|bmp|png))\2/i", $content, $matches)) { 
    6   $systeminfo['thumb'] = $matches[3][$auto_thumb_no]; 
    7  } 
    8 } 

    在这下面添加如下代码

    1 //自动提取组图为缩略图 
    2 if(isset($_POST['auto_thumbp']) && $systeminfo['thumb'] == '' && isset($modelinfo['content'])) {   
    3  $自定义字段名 = $自定义字段名 ? $自定义字段名 : stripslashes($modelinfo['自定义字段名']); 
    4  $auto_thumb_no = intval($_POST['auto_thumb_nop'])-1; 
    5  if(preg_match_all("/(=>)s(["|']?)([^ "'>]+.(gif|jpg|jpeg|bmp|png))\2/i", $自定义字段名, $matches)) { 
    6   $systeminfo['thumb'] = $matches[3][$auto_thumb_no]; 
    7  } 
    8 } 

    注意:content_model.class.php文件有两片需要添加这个代码,一处是新增加文章的时候,一处是修改文章的时候!

  • 相关阅读:
    【引用】关于closeonexec标志
    CentOS解决编码问题
    /etc/init.d/functions (转)
    centos 安装 中文 支持 语言包(转)
    vsftpd 530 错误
    __FILE__,__LINE__,FUNCTION__实现代码跟踪调试(linux下c语言编程)(转)
    C语言中可变参数的用法 va_start va_end(转)
    守护进程 setsid(转)
    /dev/null 重定向 ./sh >/dev/null 2>&1
    C# 子类调用父类构造函数
  • 原文地址:https://www.cnblogs.com/sakura-panda/p/4063151.html
Copyright © 2020-2023  润新知