22
33/*
44 * @package Ohara Youtube Embed mod
5- * @version 1.2.8
6- * @author Jessica González <missallsunday@simplemachines.org >
7- * @copyright Copyright (C) 2016 Jessica González
5+ * @version 1.2.9
6+ * @author Jessica González <suki@missallsunday.com >
7+ * @copyright Copyright (C) 2017 Jessica González
88 * @license http://www.mozilla.org/MPL/ MPL 2.0
99 */
1010
@@ -202,7 +202,7 @@ function OYTE_Main($data)
202202
203203 // Got something!
204204 else
205- $ result = '<div class="oharaEmbed youtube" id="oh_ ' . $ videoID .'" style="width: ' . (empty ($ modSettings ['OYTE_video_width ' ]) ? '480 ' : $ modSettings ['OYTE_video_width ' ]) .'px; height: ' . (empty ($ modSettings ['OYTE_video_height ' ]) ? '270 ' : $ modSettings ['OYTE_video_height ' ]) .'px;"></div> ' ;
205+ $ result = '<div class="oharaEmbed youtube" id="oh_ ' . $ videoID .'" style="width: ' . (empty ($ modSettings ['OYTE_video_width ' ]) ? '480 ' : $ modSettings ['OYTE_video_width ' ]) .'px; height: ' . (empty ($ modSettings ['OYTE_video_height ' ]) ? '270 ' : $ modSettings ['OYTE_video_height ' ]) .'px;"><noscript><a href="//www.youtube.com/watch?v= ' . $ videoID . ' ">//www.youtube.com/watch?v= ' . $ videoID . ' </a></noscript>< /div> ' ;
206206
207207 return $ result ;
208208}
@@ -247,11 +247,11 @@ function OYTE_Gifv($data)
247247 $ result = '' ;
248248
249249 if (strpos ($ data , 'http ' ) === false || strpos ($ data , '.com ' ) === false )
250- return '<video class="oharaEmbed gifv" autoplay loop style="max-width: ' . (empty ($ modSettings ['OYTE_video_width ' ]) ? '480 ' : $ modSettings ['OYTE_video_width ' ]) .'px; max-height: ' . (empty ($ modSettings ['OYTE_video_height ' ]) ? '270 ' : $ modSettings ['OYTE_video_height ' ]) .'px;" src="//i.imgur.com/ ' . $ data .'.webm">< source src="//i.imgur.com/ ' . $ data .'.webm " type="video/webm "></source></video> ' ;
250+ return '<video class="oharaEmbed gifv" autoplay loop style="max-width: ' . (empty ($ modSettings ['OYTE_video_width ' ]) ? '480 ' : $ modSettings ['OYTE_video_width ' ]) .'px; max-height: ' . (empty ($ modSettings ['OYTE_video_height ' ]) ? '270 ' : $ modSettings ['OYTE_video_height ' ]) .'px;"><source src="//i.imgur.com/ ' . $ data .'.webm" type="video/webm"></ source><source src="//i.imgur.com/ ' . $ data .'.mp4 " type="video/mp4 "></source></video> ' ;
251251
252252
253253 // We all love Regex.
254- $ pattern = '/^(?:https?:\/\/)?(?:www\.)?i\.imgur\.com\/([a-z0-9]+)\.(?:gifv|webm)/i ' ;
254+ $ pattern = '/^(?:https?:\/\/)?(?:www\.)?i\.imgur\.com\/([a-z0-9]+)\.(?:gif| gifv|webm|mp4 )/i ' ;
255255
256256 // First attempt, pure regex.
257257 if (empty ($ videoID ) && preg_match ($ pattern , $ data , $ matches ))
@@ -264,7 +264,7 @@ function OYTE_Gifv($data)
264264
265265 // Got something!
266266 else
267- $ result = '<video class="oharaEmbed gifv" autoplay loop style="max-width: ' . (empty ($ modSettings ['OYTE_video_width ' ]) ? '480 ' : $ modSettings ['OYTE_video_width ' ]) .'px; max-height: ' . (empty ($ modSettings ['OYTE_video_height ' ]) ? '270 ' : $ modSettings ['OYTE_video_height ' ]) .'px;" src="//i.imgur.com/ ' . $ videoID .'.webm">< source src="//i.imgur.com/ ' . $ videoID .'.webm " type="video/webm"></source ></video> ' ;
267+ $ result = '<video class="oharaEmbed gifv" autoplay loop style="max-width: ' . (empty ($ modSettings ['OYTE_video_width ' ]) ? '480 ' : $ modSettings ['OYTE_video_width ' ]) .'px; max-height: ' . (empty ($ modSettings ['OYTE_video_height ' ]) ? '270 ' : $ modSettings ['OYTE_video_height ' ]) .'px;"><source src="//i.imgur.com/ ' . $ videoID .'.webm" type="video/webm"></ source><source src="//i.imgur.com/ ' . $ videoID .'.mp4 " type="video/mp4" ></video> ' ;
268268
269269 return $ result ;
270270}
@@ -283,9 +283,9 @@ function OYTE_Preparse($message)
283283
284284 // The extremely long regex...
285285 $ vimeo = '~(?<=[\s>\.(; \'"]|^)(?:https?\:\/\/)?(?:www\.)?vimeo.com\/(?:album\/|groups\/(.*?)\/|channels\/(.*?)\/)?[0-9]+\??[/\w\-_\~%@\?;=#} \\\\]?~ ' ;
286- $ youtube = '~(?<=[\s>\.(; \'"]|^)(?:http|https):\/\/[\w\-_%@:|]?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/watch\?.+&v=))([\w-]{11})(?:[^\s]+)?(?=[^\w-]|$)(?![?=&+%\w.-]*(?:[ \'"][^<>]*> | <\/a> ))[?=&+%\w.-]*[\/\w\-_\~%@\?;=#} \\\\]?~ix ' ;
286+ $ youtube = '~(?<=[\s>\.(; \'"]|^)(?:http|https):\/\/[\w\-_%@:|]?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/watch\?.+&v=))([\w-]{11})(?:[^\s|\<|\[ ]+)?(?=[^\w-]|$)(?![?=&+%\w.-]*(?:[ \'"][^<>]*>| <\/a> ))[?=&+%\w.-]*[\/\w\-_\~%@\?;=#} \\\\]?~ix ' ;
287287
288- $ gifv = '~(?<=[\s>\.(; \'"]|^)(?:http|https):\/\/[\w\-_%@:|]?(?:www\.)?i\.imgur\.com\/([a-z0-9]+)\.(?:gifv|webm)(?=[^\w-]|$)(?![?=&+%\w.-]*(?:[ \'"][^<>]*> | <\/a> ))[?=&+%\w.-]*[\/\w\-_\~%@\?;=#} \\\\]?~ix ' ;
288+ $ gifv = '~(?<=[\s>\.(; \'"]|^)(?:http|https):\/\/[\w\-_%@:|]?(?:www\.)?i\.imgur\.com\/([a-z0-9]+)\.(?:gif| gifv|webm|mp4 )(?=[^\w-]|$)(?![?=&+%\w.-]*(?:[ \'"][^<>]*> | <\/a> ))[?=&+%\w.-]*[\/\w\-_\~%@\?;=#} \\\\]?~ix ' ;
289289
290290 // Is this a YouTube video url?
291291 $ message = preg_replace_callback (
0 commit comments