10/13/2017

Facebook for Discuz! 代碼編輯器

參考來源
https://besv.net/thread-1110-1-1.html
https://besv.net/thread-1170-1-1.html

 

原始代碼

<script>
var URL = encodeURIComponent("{1}");
document.write('<iframe width="560" height="315" style="max-width:90%" src="//www.facebook.com/plugins/video.php?href='+URL+'" frameborder="0" allowfullscreen></iframe>');
</script>


Closure Compiler 優化代碼

<script>var URL=encodeURIComponent("{1}");document.write('<iframe width="560" height="315" style="max-width:90%" src="//www.facebook.com/plugins/video.php?href='+URL+'" frameborder="0" allowfullscreen></iframe>');</script>


回應式代碼

<div style="position:relative;padding-bottom:56.25%;width:100%;height:0;"><script>var URL=encodeURIComponent("{1}");document.write('<iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" src="//www.facebook.com/plugins/video.php?href='+URL+'" frameborder="0" allowfullscreen></iframe>');</script></div>


回應式代碼 for bbcode

路徑 source/function/function_discuzcode.php
function_discuzcode-Facebook.patch


if(strpos($msglower, '[/email]') !== FALSE) {
$message = preg_replace("/\[email(=([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+))?\](.+?)\[\/email\]/ies", "parseemail('\\1', '\\4')", $message);
}

下面添加

if(strpos($msglower, '[/facebook]') !== FALSE) {
$message = preg_replace("/\[facebook](.+?)\[\/facebook\]/ies", "parsefacebook('\\1')", $message);
}



function parsetable($width, $bgcolor, $message) {

上面添加

function parsefacebook($url) {
return '<div style="position:relative;padding-bottom:56.25%;width:100%;height:0;"><iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" src="//www.facebook.com/plugins/video.php?href='.$url.'" frameborder="0" allowfullscreen></iframe></div>';
}


下載 Facebook 圖示
Facebook-social_icon_pack-blue-GIF.zip

適用版本 Discuz X3.2 R20160601

 

測試網址

[facebook]https://www.facebook.com/1theK/videos/1145946925452501/[/facebook]




 




 

回應式代碼 for bbcode

路徑 source/function/function_discuzcode.php
function_discuzcode-Facebook_V2.patch

適用版本 Discuz X3.3 R20170401

  • 支援 PHP7


 

沒有留言:

張貼留言