<ruby id="jxxzj"></ruby>
      <th id="jxxzj"><form id="jxxzj"></form></th>

          <sub id="jxxzj"><progress id="jxxzj"></progress></sub>

          <track id="jxxzj"></track>
          <th id="jxxzj"><form id="jxxzj"></form></th>

          <th id="jxxzj"><progress id="jxxzj"><listing id="jxxzj"></listing></progress></th>
            <th id="jxxzj"></th>

            <video id="jxxzj"><big id="jxxzj"><th id="jxxzj"></th></big></video>

            <track id="jxxzj"><progress id="jxxzj"><listing id="jxxzj"></listing></progress></track>
              <address id="jxxzj"></address><video id="jxxzj"><progress id="jxxzj"></progress></video>
              VIP福利
              主頁 > 建站問題 > 織夢技巧 > 織夢文檔內容圖片自動添加a鏈接新窗口打開圖片

              織夢文檔內容圖片自動添加a鏈接新窗口打開圖片

              沒整之前 整完之后 第一種實現方法,jquery script type = text/javascript $( function () { $( .show-article img ).each( function ( i ) { if (! this .parentNode.href) { $( this ).wrap( a href= + this .src+ target=_blank/a ); } }); }); / script 注意: 1、前提是你當前頁面有jquery庫 2、你的文檔內容 […]



              沒整之前

              整完之后

              第一種實現方法,jquery

              <script type="text/javascript">
                  $(function() {
                      $('.show-article img').each(function(i){
                          if (!this.parentNode.href) {
                              $(this).wrap("<a href='"+this.src+"' target='_blank'></a>");
                          }
                      });
                  });
              </script>

              注意:

              1、前提是你當前頁面有jquery庫

              2、你的文檔內容外圍div里的class或者id,改成自己的

              第二種實現方法,PHP

              1、在 /include/extend.func.php 最下面加入

              /**
               *  文檔內容圖片自動添加a鏈接新窗口打開圖片
               *
               * @access    public
               * @param     string $body 內容
               * @return    string
               */
              function setBodyimg($body)
              {
                  $matches = array();
                  preg_match_all('/<img[^>]*src\s*=\s*([\'"]?)([^\'">]*)\1(.*?)>/isu', $body, $matches);
                  $img_array = $matches[0];
                  $src_array = $matches[2];
                  foreach ($img_array as $key => $value)
                  {
                      $body = str_replace($value, "<a href='{$src_array[$key]}' target='_blank'>".$value."</a>", $body);
                  }
                  return $body;
              }

              2、把內容模板里的調用內容的標簽

              {dede:field.body/}

              改成

              {dede:field.body function="setBodyimg(@me)"/}

              完成


              說點什么吧
              • 全部評論(0
                還沒有評論,快來搶沙發吧!

              韩国全部三级伦在线观看 - 视频 - 在线观看 - 电影影院 - 品赏网