• DedeCMS文章里图片ALT注释自动填充为文章标题


    本文修改下面代码后,可将图片的ALT注释设置为文章标题。

    具体方法:

    首先找到文件 includearc.archives.class.php

     //设置全局环境变量
    $this->Fields['typename'] = $this->TypeLink->TypeInfos['typename'];
    SetSysEnv($this->Fields['typeid'],$this->Fields['typename'],$this->Fields['id'],$this->Fields['title'],’archives’);
    }

    将以上代码,替换为以下代码:

    //设置全局环境变量

    $this->Fields['typename'] = $this->TypeLink->TypeInfos['typename'];
    @SetSysEnv($this->Fields['typeid'],$this->Fields['typename'],$this->Fields['id'],$this->Fields['title'],’archives’);
    $this->Fields['body'] = str_ireplace(array(‘alt=”"‘,’alt=’”),”,$this->Fields['body']);
    $this->Fields['body'] = preg_replace(“@ [s]{0,}alt[s]{0,}=["'s]{0,}[sS]{0,}["'s] @isU”,” “,$this->Fields['body']);
    $this->Fields['body'] = str_ireplace(“<img ” ,”<img alt=”".$this->Fields['title'].”” “,$this->Fields['body']);
    $this->Fields['imgurls'] = str_ireplace(array(‘alt=”"‘,’alt=’”),”,$this->Fields['imgurls']);
    $this->Fields['imgurls'] = preg_replace(“@ [s]{0,}alt[s]{0,}=["'s]{0,}[sS]{0,}["'s] @isU”,” “,$this->Fields['imgurls']);
    $this->Fields['imgurls'] = str_ireplace(“<img ” ,”<img alt=”".$this->Fields['title'].”” “,$this->Fields['imgurls']);
    }
    另一个写法
    //设置全局环境变量
       $this->Fields['typename'] = $this->TypeLink->TypeInfos['typename'];
       @SetSysEnv($this->Fields['typeid'],$this->Fields['typename'],$this->Fields['id'],$this->Fields['title'],'archives');
                 //替换图片描述为标题
                $this->Fields['body'] = str_ireplace("<img " ,"<img alt='".$this->Fields['title'].",吧dedecms8.com",$this-> Fields['body']);
                $this->Fields['imgurls'] = str_ireplace("<img " ,"<img alt='".$this->Fields['title'].",织梦吧dedecms8.com' ",$this->Fields['imgurls']);
                $this->Fields['introduce'] = str_ireplace("<img " ,"<img alt='".$this->Fields['title'].",织梦吧dedecms8.com' ",$this->Fields['introduce']); 
      }


    将以上代码替换完成后,更新文档HTML,就可以了。

    清风明月本无价,近水远山皆有情。
  • 相关阅读:
    9、par画图参数
    awk
    Android Studio Gradle下载的包在哪里?
    .net core webapi 在原有基础上修改。
    .net core webapi 部署到 IIS
    原来部署好的WCF(可以调用),因为部署.net core,而安装了DotNetCore.2.0.5-WindowsHosting,导致现在WCF站点不可以。
    sql2008R2新建链接服务器。
    Dynamics CRM 365常用js记录。
    <div>标签输入文字
    dynamics crm 365 附件上传图片并且显示。
  • 原文地址:https://www.cnblogs.com/onlylove2015/p/4394109.html
Copyright © 2020-2023  润新知