Dedecms圖片加上Alt和Title等屬性的修改方法

字號:


    Dedecms發(fā)表資訊等等上傳的圖片全部沒有title,雖然有這個選項卻不生效,于是就研究了一下,發(fā)現(xiàn)只需要在相關文件添加一段代碼即可。先告知大家方法,希望更多的人能夠受益
    找到include文件夾下面的arc.archives.class.php文件,打開,記得不能用記事本打開,可以在dedecms后臺文件管理里面打開或者notepad++等軟件打開。
    找到下面這段代碼:
    代碼如下:
    //設置全局環(huán)境變量
    $this->Fields['typename'] = $this->TypeLink->TypeInfos['typename'];
    @SetSysEnv($this->Fields['typeid'],$this->Fields['typename'],$this->Fields['id'],$this->Fields['title'],'archives');
    }
    //完成附加表信息讀取
    unset($row);
    大概在第204行。
    然后在
    代碼如下:
    @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'].",腳本之家' ",$this->Fields['body']);
    $this->Fields['imgurls'] = str_ireplace("<img " ,"<img alt='".$this->Fields['title'].",腳本之家' ",$this->Fields['imgurls']);
    $this->Fields['introduce'] = str_ireplace("<img " ,"<img alt='".$this->Fields['title'].",腳本之家' ",$this->Fields['introduce']);
    其中的“腳本之家”可以更換成你想要更換的文字。