易优cms怎么替换图片alt为文章标题?
更新日期:2024-06-22 16:38:24 来源:网络
在extend/function.php里添加自己的修改方法:
//替换图片alt为文章标题
function diy_replace_imgalt($title,$content){
$pattern = '/alt="*"/i';
preg_match_all($pattern,$content,$match);
//return var_dump($match);
if($match[0][0]=='alt=""'){
return preg_replace($pattern,"alt=$title",$content);
}
if($match[0][0]==null){
$pattern= '/<img */i';
preg_match_all($pattern,$content,$match);
return preg_replace($pattern,"<img alt=$title ",$content);
}
else{
return $content;
}
}
然后在view-article.htm里面调用函数
{$eyou.field.title,$eyou.field.content|diy_replace_imgalt}
即可。
//替换图片alt为文章标题
function diy_replace_imgalt($title,$content){
$pattern = '/alt="*"/i';
preg_match_all($pattern,$content,$match);
//return var_dump($match);
if($match[0][0]=='alt=""'){
return preg_replace($pattern,"alt=$title",$content);
}
if($match[0][0]==null){
$pattern= '/<img */i';
preg_match_all($pattern,$content,$match);
return preg_replace($pattern,"<img alt=$title ",$content);
}
else{
return $content;
}
}
然后在view-article.htm里面调用函数
{$eyou.field.title,$eyou.field.content|diy_replace_imgalt}
即可。
- 易优cms怎么替换图片alt为文章标题?
- 易优cms怎么关闭网站后台登陆验证码
- 易优cms言提交出现图片验证码不能为空怎么办
- 安装完登录报错:Array and string offset access syntax with curly braces is deprecated
- SQLSTATE[42S02]: Base table or view not found: 1146 Table '***.ey_citysite' doesn't e
- 易优cms数据表或视图不存在,请联系技术处理。
- 报错 /core/library/think/Template.php 第 591 行左右 Maximum execution time of 30 secon
- [错误代码] SQLSTATE[HY000]: General error: 145 Table '.\com\ey_tagindex' is marked as crashe
- 错误代码:SQLSTATE[HY000]: General error: 145 Table '.
- 报错 /core/library/think/db/Connection.php 第 380 行左右
- 类型错误: implode(): Argument #1 ($pieces) must be of type array, string given
- 网站打开报错 \core\library\think\db\Connection.php
- SQLSTATE[HY000] [1045] Access denied for user 'cs2021'@'localhost' (using passwo
- 报错 \core\library\think\db\Connection.php 第 307 行左右,访问被拒,这样的情况要怎么处理啊
- 报错\data\runtime\temp\5b16e68487528591ef11baffaccbc251.php 第 259 行左右 Can‘t use method return val
- php5.4版本,报错:Can't use method return value in write context
- 报错\corelibrary\think\cache\driver\File.php
- 系统报错:unserialize(): Error at offset 0 of 1571 bytes
- 易优cms数据库配置文件是哪个
- 连接数据库失败,请查看配置文件