Chỉ cần chèn link youtube vào bài viết, đoạn code dưới đây sẽ chuyển link đó thành 1 video youtube tương ứng.
DEMO: (Tương tự như dùng thẻ [youtube][/youtube])
DEMO: (Tương tự như dùng thẻ [youtube][/youtube])
ACP >> Modules >> Javascript codes management >> Tạo 1 java script mới
Title*: Tùy thích
Placement: In all the pages
Javascript Code*:
Code:
$(function () {
// Auto youtube transform
// Hancki - FdF
$('.post-entry a, .postbody .content a, .postbody a').html(function (i, html) {
return html.replace(/(?:https:\/\/)?(?:http:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/g, '<iframe width="420" height="345" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>');
});
});