HTML:
<!--parser:xtscript-->
function youtube $link=http://m.youtube.com/watch?hl=vi&client=mv-google&gl=US&v=vkWwEgZrbmc;
var $i = <xt:get_device_template />
if $i==web
var $h = 375
var $w = 500
else
var $h = 180
var $w = 240
endif
var $l = call strlen $val=$link
if $l == 11
var $id = $link
else
var $start = call strpos $haystack=$link;$needle=v=;
var $start = ($start+2)
var $id = call substr $val=$link;$start=$start;$length=11;
endif
print <div class="video"><object type='application/x-shockwave-flash' data='http://www.youtube.com/v/$id' width='$w' height='$h'> <param name='movie' value='http://www.youtube.com/v/$id' /> <param name='quality' value='default' /><param name='allowFullScreen' value='true' /> <!-- Fallback content --><a onclick='_gaq.push(['_trackEvent', 'Outgoing', 'www.youtube.com', '/watch?v=$id'])' href='$link'> YouTube Video:<br /><img src='http://img.youtube.com/vi/$id/0.jpg' width='$w' height='$h' alt='Click here to view on youtube' /></a></object></div>
endfunction
<!--/parser:xtscript-->
HTML:
<!--parser:xtscript-->
call youtube $link=link youtube
<!--/parser:xtscript-->
HTML:
<xt:call function="youtube" link="link youtube">
Dùng link mobile hoặc id cũng ok
Demo v-star.wap.sh
Demo áp dụng làm bbcode cho xtblog: Larva - Laughing (****)|Blog|2|v-star.wap.sh
Lưu ý:
- include thì dùng call @youtube
- Không nên dùng include vì sẽ tăng thời gian xử lý của server => lag. (inc: 5x-7x, không inc: 0x-1x)
Nguồn: V-STAR