<?php
$_content = '<p class="post_content">[iframe width="256" height="175" src="http://www.youtube.com/embed/ICx3AfSlc-w" frameborder="0" allowfullscreen]</p>
//www.youtu.be/asdlfkjad_1
https://www.youtube.com/watch?v=dZpc936_Hgo
http://youtu.be/lvOFck4dn_8
http://vimeo.com/65484727
http://www.metacafe.com/watch/10599819/are_katy_perry_and_john_mayer_back_together
http://www.dailymotion.com/video/xzdijh_hire-data-entry-expert_news
<embed style="width:400px; height:326px;" wmode="opaque" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=123456&hl=en" flashvars=""> </embed>
<embed src="http://blip.tv/play/gaUIx5A7AA" type="application/x-shockwave-flash" width="320" height="270" allowscriptaccess="always" allowfullscreen="true"></embed>
<iframe width="575" height="324" src="http://cache.vevo.com/m/html/embed.html?video=GBA320903400&autoplay=1" frameborder="0" allowfullscreen></iframe>
https://www.facebook.com/FacebookDevelopers/posts/10151471074398553
https://www.facebook.com/video/embed?video_id=10152778880075249
"https://www.facebook.com/FacebookDevelopers/videos/10152454700553553/"
<div class="post_source_linkbar">
<img class="post_source_logo" src="http://economyincrisis.org/wp-content/uploads/2011/08/EICtext5.png"><img class="post_source_icon" title="Economy In Crisis" src="http://www.google.com/s2/favicons?domain=http%3A%2F%2Feconomyincrisis.org%2F">Source</div>';
function media_add($a) {
global $_media_list; $_media_list[] = $a[0]; return '';
}
function embedded_media($content) {
global $_media_list; $_media_list = array(); preg_replace_callback(array(
'/(https?:|)\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[?=&+%\w-]*/i',
'/(https?:|)\/\/vimeo\.com\/(\d+)/i',
'/(https?:|)\/\/www\.metacafe\.com\/watch\/(\d+)\/(\w+)/i',
'/(https?:|)\/\/www\.dailymotion\.com[^\/]*\/video\/(\w+)/i',
'/(https?:|)\/\/blip.tv\/play\/(\w+)/i',
'/(https?:|)\/\/(?:[0-9A-Z-]+\.)?vevo\.com[^\?]+\?video\=(\w+)/i',
'/(https?:|)\/\/www\.facebook\.com\/([^\?]+\?video_id\=(\w+)|[^\/]*\/videos\/(\w+))/i',
), 'media_add', $content);
return $_media_list;
}
var_dump(embedded_media($_content));
- Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.2.29 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
- array(11) {
[0]=>
string(40) "http://www.youtube.com/embed/ICx3AfSlc-w"
[1]=>
string(26) "//www.youtu.be/asdlfkjad_1"
[2]=>
string(43) "https://www.youtube.com/watch?v=dZpc936_Hgo"
[3]=>
string(27) "http://youtu.be/lvOFck4dn_8"
[4]=>
string(25) "http://vimeo.com/65484727"
[5]=>
string(82) "http://www.metacafe.com/watch/10599819/are_katy_perry_and_john_mayer_back_together"
[6]=>
string(44) "http://www.dailymotion.com/video/xzdijh_hire"
[7]=>
string(30) "http://blip.tv/play/gaUIx5A7AA"
[8]=>
string(58) "http://cache.vevo.com/m/html/embed.html?video=GBA320903400"
[9]=>
string(135) "https://www.facebook.com/FacebookDevelopers/posts/10151471074398553
https://www.facebook.com/video/embed?video_id=10152778880075249"
[10]=>
string(68) "https://www.facebook.com/FacebookDevelopers/videos/10152454700553553"
}
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
array(11) {
[0]=>
string(40) "http://www.youtube.com/embed/ICx3AfSlc-w"
[1]=>
string(26) "//www.youtu.be/asdlfkjad_1"
[2]=>
string(43) "https://www.youtube.com/watch?v=dZpc936_Hgo"
[3]=>
string(27) "http://youtu.be/lvOFck4dn_8"
[4]=>
string(25) "http://vimeo.com/65484727"
[5]=>
string(82) "http://www.metacafe.com/watch/10599819/are_katy_perry_and_john_mayer_back_together"
[6]=>
string(44) "http://www.dailymotion.com/video/xzdijh_hire"
[7]=>
string(30) "http://blip.tv/play/gaUIx5A7AA"
[8]=>
string(58) "http://cache.vevo.com/m/html/embed.html?video=GBA320903400"
[9]=>
string(135) "https://www.facebook.com/FacebookDevelopers/posts/10151471074398553
https://www.facebook.com/video/embed?video_id=10152778880075249"
[10]=>
string(68) "https://www.facebook.com/FacebookDevelopers/videos/10152454700553553"
}
preferences:
148.92 ms | 403 KiB | 222 Q