فهرست منبع

#196 youtube embed filter for htmlpurifier

Alex Trofimov 11 سال پیش
والد
کامیت
f4b69216cd
1فایلهای تغییر یافته به همراه4 افزوده شده و 3 حذف شده
  1. 4 3
      plugins/htmlpurifier/standalone/HTMLPurifier/Filter/YoutubeIframe.php

+ 4 - 3
plugins/htmlpurifier/standalone/HTMLPurifier/Filter/YoutubeIframe.php

@@ -14,9 +14,10 @@ class HTMLPurifier_Filter_YoutubeIframe extends HTMLPurifier_Filter
                     $width = $width[1];
                     preg_match('/height="([0-9]+)"/', $item, $height);
                     $height = $height[1];
-                    preg_match('/https?:\/\/www\.youtube\.com\/embed\/(https?:\/\/www.youtube.com\/v\/)?([a-zA-Z0-9_-]+)/', $item, $id);
-                    $id = $id[2];
-                    $html = str_replace($result[0][$key], '<img class="YouTubeIframe" width="' . $width . '" height="' . $height . '" src="http://www.youtube.com/embed/' . $id . '?wmode=opaque">', $html);
+                    preg_match('/((https?:\/\/www\.youtube\.com\/embed\/)|(https?:\/\/www\.youtube-nocookie\.com\/embed\/)|(https?:\/\/www.youtube.com\/v\/))([a-zA-Z0-9_-]+)/', $item, $id);
+                    $id = $id[5];
+                    $sProto = 0 == strncmp('https', BX_DOL_URL_ROOT, 5) ? 'https' : 'http';
+                    $html = str_replace($result[0][$key], '<img class="YouTubeIframe" width="' . $width . '" height="' . $height . '" src="' . $sProto . '://www.youtube-nocookie.com/embed/' . $id . '?rel=0">', $html);
                 }
             }
         }