ppypp伦理天堂,91手机在线视频,免费在线观看黄色毛片,夜夜穞天天穞狠狠穞AV美女按摩

聯(lián)系官方銷(xiāo)售客服

1835022288

028-61286886

投訴 已解決 想實(shí)現(xiàn)把文章里的圖片為絕對(duì)路徑,又同時(shí)去除img中的style 3 0
迅睿CMS版本:4.5.2

想實(shí)現(xiàn)把文章里的圖片為絕對(duì)路徑,又同時(shí)去除img中的style。求大神幫忙!

{php echo preg_replace('/(<img.*?)(style=.+?[\'|"])/i','$1',$content);} 這個(gè)是去除img里的style

{php echo preg_replace('/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i',"<img src=\"".SITE_URL."$1\">", $content);} 這個(gè)是圖片替換為絕對(duì)路徑


以上兩個(gè)表達(dá)式單獨(dú)放一個(gè)都沒(méi)啥問(wèn)題,但兩個(gè)放一塊就只能實(shí)現(xiàn)一個(gè)功能,有大神知道如何同時(shí)實(shí)現(xiàn)以上兩個(gè)功能嗎?表達(dá)式應(yīng)該怎么寫(xiě)?

解決方案
  • 在這個(gè)字段,的數(shù)據(jù)驗(yàn)證里有個(gè)過(guò)濾函數(shù),你把上面的寫(xiě)成函數(shù)調(diào)用一下就好了

    參考文檔:《自定義過(guò)濾函數(shù)》

  • {php $content = preg_replace('/(<img.*?)(style=.+?[\'|"])/i','$1',$content);}
    {php echo preg_replace('/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i',"<img src=\"".SITE_URL."$1\">", $content);}

    這是php基礎(chǔ)語(yǔ)法

    滿意答案
    開(kāi)源積分+10
  • 1、打開(kāi) config/custom.php 添加自定義函數(shù)

    /*

    * 文檔內(nèi)容-圖片去寬高自適應(yīng)-圖片絕對(duì)路徑

    * @param string $body

    * @return string 返回內(nèi)容

    */

    if(!function_exists('resetBody'))

    {

    function resetBody($body)

    {

    $search = '/(<img.*?)width=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';

    $search1 = '/(<img.*?)height=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';

    $search2 = '#(<img.*?style=".*?)width:\s{0,}\d+px;([^"]*?.*?>)#i';

    $search3 = '#(<img.*?style=".*?)height:\s{0,}\d+px;([^"]*?.*?>)#i';

    $content = preg_replace($search, '$1$3', $body);

    $content = preg_replace($search1, '$1$3', $content);

    $content = preg_replace($search2, '$1$2', $content);

    $content = preg_replace($search3, '$1$2', $content);

    $result = str_replace('/uploads/', SITE_URL . '/uploads/', $content);

    return $result;

    }

    }

    2、模板調(diào)用文檔內(nèi)容標(biāo)簽

    {$content}

    改成

    {resetBody($content)}

    高端程序員往往采用最樸素的編程方式,若不是貧窮,誰(shuí)愿意弄的自己一身才華!
  • @官方研發(fā)技術(shù)-袁老師:厲害了我的哥,服務(wù)到位。技術(shù)過(guò)硬!