jQuery(function($){
$.fn.youtubeResponsive = function( ratio ) {
return this.each(function() {
var _this = $(this);
var _wrap = $('<div class="youtube-responsive-wrapper" />');
var ratio = ratio || 16/9;
_this.css({
position: 'absolute',
top: 0,
left: 0,
width: 100+'%',
height: 100+'%',
});
_wrap.css({
position: 'relative',
width: 100+'%',
marginLeft: 'auto',
marginRight: 'auto',
height: 0,
paddingTop: 100/ratio+'%',
});
_this.wrap(_wrap);
});
};
//How to trigger
$('iframe[src*="youtube"]').youtubeResponsive(16/9);
});
Just auto responsive size for Youtube embed.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.