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

织梦程序使用教程
DedeCMS文章里图片ALT注释自动填充为文章标题


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


具体方法:


首先找到文件 \include\arc.archives.class.php




//设置全局环境变量

$this->Fields['typename'] = $this->TypeLink->TypeInfos['typename'];

SetSysEnv($this->Fields['typeid'],$this->Fields['typename'],$this->Fields['id'],$this->Fields['title'],rsquo;archivesrsquo;);

}



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







//设置全局环境变量


$this->Fields['typename'] = $this->TypeLink->TypeInfos['typename'];

@SetSysEnv($this->Fields['typeid'],$this->Fields['typename'],$this->Fields['id'],$this->Fields['title'],rsquo;archivesrsquo;);

$this->Fields['body'] = str_ireplace(array(lsquo;alt=""lsquo;,rsquo;alt=\rsquo;\"),",$this->Fields['body']);

$this->Fields['body'] = preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU"," ",$this->Fields['body']);

$this->Fields['body'] = str_ireplace("\"".$this-Fields['title']."\" ",$this->Fields['body']);

$this->Fields['imgurls'] = str_ireplace(array(lsquo;alt=""lsquo;,rsquo;alt=\rsquo;\"),",$this->Fields['imgurls']);

$this->Fields['imgurls'] = preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU"," ",$this->Fields['imgurls']);

$this->Fields['imgurls'] = str_ireplace("\"".$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("".$this->Fields[织梦吧dedecms8.com",$this->Fields['body']);

$this->Fields['imgurls'] = str_ireplace("".$this->Fields[ $this->Fields['introduce'] = str_ireplace("".$this->Fields[ }





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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值