織夢(mèng)怎么讓文章中圖片自動(dòng)添加ALT屬性
function replaceurl($newurl)
{
global $dsql,$id;
//獲取圖片附加表imgurls字段內(nèi)容進(jìn)行處
$row = $dsql->GetOne("SELECT title FROM dede_archives where id=$id");
//替換圖片Alt為文檔標(biāo)題
$newurl=str_ireplace(array('alt=""','alt=/'/''),'',$newurl);
$newurl=preg_replace("@ [/s]{0,}alt[/s]{0,}=[/"'/s]{0,}[/s/S]{0,}[/"'/s] @isU"," ",$newurl);
$newurl=str_ireplace("<img " ,"<img alt=/"".$row['title']."/"",$newurl);
//去掉結(jié)尾空格
$newurl=str_ireplace(" /","/",$newurl);
$newurl=str_ireplace(" />","/>",$newurl);
return $newurl;
}
|
//文章body優(yōu)化替換
function replaceurl($newurl)
{
global $dsql,$id;
//獲取圖片附加表imgurls字段內(nèi)容進(jìn)行處
$row = $dsql->GetOne("SELECT title FROM dede_archives where id=$id");
//去掉img的width和height
$newurl=preg_replace('/style=/"width/:(.*)/"/','',$newurl);
//替換圖片Alt為文檔標(biāo)題
$newurl=str_ireplace(array('alt=""','alt=/'/''),'',$newurl);
$newurl=preg_replace("@ [/s]{0,}alt[/s]{0,}=[/"'/s]{0,}[/s/S]{0,}[/"'/s] @isU"," ",$newurl);
$newurl=str_ireplace("<img " ,"<img alt=/"".$row['title']."/"",$newurl);
//去掉結(jié)尾空格
$newurl=str_ireplace(" /","/",$newurl);
$newurl=str_ireplace(" />","/>",$newurl);
return $newurl;
}
|
上一篇:關(guān)于DEDECMS的URL優(yōu)化的一些心得
欄 目:dedecms
下一篇:DedeCMS使用擴(kuò)展函數(shù)調(diào)用任意數(shù)據(jù)表的方法
本文標(biāo)題:織夢(mèng)怎么讓文章中圖片自動(dòng)添加ALT屬性
本文地址:http://www.jygsgssxh.com/a1/dedecms/13749.html
您可能感興趣的文章
- 08-05網(wǎng)站底部版權(quán)符號(hào)怎么打出來?
- 08-05Dedecms文件目錄結(jié)構(gòu)解說(能知道織夢(mèng)每個(gè)文件有什么用)
- 08-05織夢(mèng)DedeCMS獲取當(dāng)前欄目文章數(shù)量
- 08-05織夢(mèng)模板如何添加和調(diào)用自定義字段的方法
- 08-05織夢(mèng)DedeCMS調(diào)用顯示discuz里面主題的方法
- 08-05限制織夢(mèng)會(huì)員每天投稿數(shù)量方法
- 08-05常用的織夢(mèng)dedecms安全設(shè)置集合整理
- 08-05織夢(mèng)教程:后臺(tái)編輯器添加中文字體方法
- 08-05織夢(mèng)修改文章排序到第一位如何解決?
- 08-05dede副欄目調(diào)用支持arclist標(biāo)簽




