dede织梦CMS模板实现图片ALT属性自动换成标题的代码

第一步,\include\taglib\channel\img.lib.php
文件,第77行左右,加上 $dsql= new DedeSql(false);//建立新连接 $rs = $dsql->GetOne("Select title from cmsxx_archives where"); //打开数据库 $title=$rs["title"]; //找到标题值 第107行左右 加一句 $fields['title'] = str_replace("'",'',$title); 我说左右因为是同类语句中放哪都行。 第二步,把article_image.htm中的 alt='[field:alttext /]' 换为: alt='[field:title /]' 第三步,生成,搞定