本帖最後由 Fly_Bird 於 2013-10-21 13:44 編輯
7 k0 @2 m* ^% f
* K6 j5 U) b* A" ~6 _( G一、將下面代碼加到Wordpress主題functions.php模板文件中:- function youku_video($atts, $content=null){ - n6 I1 |( ~# R$ ^. Z
- return '<p style="text-align: center;"><embed src=[flash]http://static.youku.com/v1.0.0149/v/swf/loader.swf?VideoIDS='.$content.'ID&winType=adshow&isAutoPlay=true[/flash] quality="high" width="610" height="460" align="middle" wmode="transparent" allowScriptAccess="never" allowNetworking="internal" autostart="0" type="application/x-shockwave-flash"></embed></p>'; 0 Y r" z5 n' O! }# X; G5 k1 S
- } $ w, W7 L6 v7 C4 ?& @
- add_shortcode('youku','youku_video');
複製代碼 其中: width="610" height="460" 是視頻的大小,可根據需要修改。
4 p( w2 F4 W [, k2 ?二、編輯文章時在準備插入優酷視頻的位置輸入:- {youku]XMjM2OTE3ODg4[/youku}
複製代碼 中間的「XMjM2OTE3ODg4」是這首 ]Need You Now[/url] 音樂視頻地址的ID:: O3 j1 N2 Y# b+ b; r
[flash]http://player.youku.com/player.php/sid/[/url]XMjM2OTE3ODg4/v.swf[/flash]
& F4 i+ B2 `6 u獲得視頻地址後,只需要複製最後的紅色部即可。" e5 D# g1 R5 I( |- g% m2 g6 L
點擊播放下面的視頻,看看煩人廣告是不是真的沒了,再也不會因看一分鐘的視頻,卻因為前面30秒的廣告而抓狂!
- j9 F% \1 b7 G- F! `4 m& x$ @ E6 {- h
本文的目的只是為了實踐應用一下WP短代碼而已,如果你是Firefox或者chrome瀏覽器用戶,可以安裝Adblock擴展屏蔽視頻廣告,更為方便實用。$ b) N* x" x' f# N- s" t
另外,OpenGG.Clean.Player 去視頻廣告腳本也不錯
8 a! O% g9 I4 N* N補充:另有童鞋在此代碼基礎上添加了可以自定義視頻大小的短代碼供大家參考:- /優酷開始 - j+ Y& R$ t% {) n' x
- function youku_video($atts, $content=null){
9 U3 g" a0 {5 F. ]9 |6 v - extract(shortcode_atts(array("w"=>'0',"h"=>'0',),$atts));
% g: a- n' H6 J5 U7 l, A- o( a& a" r8 b - return '<p style="text-align: center;"><embed src=[flash]http://static.youku.com/v1.0.0149/v/swf/loader.swf?VideoIDS='.$content.'ID&winType=adshow[/flash] quality="high" width="'.$w.'" height="'.$h.'" align="middle" wmode="transparent" allowScriptAccess="never" allowNetworking="internal" autostart="0" type="application/x-shockwave-flash"></embed></p>'; 2 E2 Y5 U2 Q% e! u9 I1 f
- }9 s# q' p4 x- s" o
- add_shortcode('youku','youku_video');
* z9 b: C: x6 y; v4 i - //優酷結束
複製代碼 編輯文章時在準備插入優酷視頻的位置輸入:- {youku w=630 h=370]XMzMyMzgzNjI4[/youku}
複製代碼 註:前後的 { } 用 [ ] 替換。 k# t6 w; {$ y9 F4 w) B
其中 w=630 h=370是視頻尺寸大小
$ ?" G0 s& h" g; Y' F. S0 w4 _! r. {
6 }; _% K; s) ^) ?--------------------------------------------------------------------------------------------------& y( w7 Y2 I b& h4 Y/ P
註:上面的視頻還是有廣告,因為只有在該方法只是針對wordpress上發視頻,我通過firefox瀏覽器瀏覽wordpress上的該視頻時確實是沒廣告的。
# b( i1 h5 r Q& O( X8 E `最後我是 轉載自 http://zmingcx.com/youku-wordpress-code-ad.html
# U1 w0 G2 R7 |5 M0 C
: y' Z( ?- {) I- Z; v- }
" Z0 V! A8 ?: ~+ R# x' O: w9 o- \9 s: {- l" \
: j0 C6 g0 I$ X' y
: E S+ H! }% Y" [+ z, g) {
t3 v! T- B+ e, L7 k, D( K
|