1. <small id="v0pg0"></small>

    2. 
      
      <sup id="v0pg0"></sup><output id="v0pg0"><nobr id="v0pg0"><delect id="v0pg0"></delect></nobr></output>
    3. 您现在的位置: 首页 > 新闻 > 建站常识

      destoon改造MIP文章内容img正则替换mip-img方法

      来源:网络公司发布时间:2021-04-26热度:29354

       

      首先第一步,找到你修改的模块,我以资讯模块为例:

      路径为:/module/article/show.inc.php

      然后打开,大概在18行左右 插入一下代码,进行正则替换


      function mip_replace($content = ''){
      $pattern1 = "#<img.*?src=['\"](.*?)['\"].*?>#ims";
      $imgcontent=array();
      preg_match_all($pattern1,$content,$img);
      $imgcontent = $img[0];
      $imgurl = $img[1];
      foreach($imgcontent as $imgk=>$imgv)
      {
      $temp =  str_replace('<img','mip-img',$imgv);
      $temp = str_replace('/>','></mip-img',$temp);
      $url = $imgurl[$imgk];
      $url = mip_format_img_url($url);
      $temp = preg_replace("/src=['\"].*?['\"]/si","src=http://www.healthmedicexpressnowcialis365.com/skin/mall/image/nopic.gif>
      $mipimg[$imgk] = $temp;
      }
      $content = preg_replace($imgcontent,$mipimg,$content);
      $content =preg_replace("/<a /si","<a target=\"_blank\" ",$content);
      $content =preg_replace("/style=\".*?\"/si","",$content);
      return mip_utf8($content);
      }
      function mip_format_img_url( $url = ''){
      if(stripos($url, 'http') === 0 || stripos($url, 'ftp') === 0 ){
      return $url;
      }
      if(stripos($url, '/') === 0){
      $url = 'http://'.$_SERVER['HTTP_HOST'].$url;
      }else{
      $url = 'http://'.$_SERVER['HTTP_HOST'].'/'.$url;
      }
      return $url;
      }
      function mip_utf8($string = '') {
      $fileType = mb_detect_encoding($string , array('UTF-8','GBK','LATIN1','BIG5'));
      if( $fileType != 'UTF-8'){
      $string = mb_convert_encoding($string ,'utf-8' , $fileType);
      }
      return $string;
      }
      $content=mip_replace($content);

      本文来源:http://www.healthmedicexpressnowcialis365.com/news/show-1642.html
      鸥美A片

        1. <small id="v0pg0"></small>

        2. 
          
          <sup id="v0pg0"></sup><output id="v0pg0"><nobr id="v0pg0"><delect id="v0pg0"></delect></nobr></output>