Lead coder: biohzrdmx <github.com/biohzrdmx>
The MIT License (MIT)
Copyright (c) 2013 biohzrdmx
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Just create a placeholder element and give some
data attributes to it. It's that simple.
data-id attribute specifies the video ID: for
http://www.youtube.com/watch?v=oX6I6vs1EFs that would be
<div data-id="oX6I6vs1EFs" class="demo01"></div>
LazyTube automagically fetches the preview image so you don't have to worry on doing it, and the video will be loaded when you click on it:
Data attributes are the way to go, just add some
<div data-id="oX6I6vs1EFs" data-width="480" data-height="320" class="demo02"></div>
You may also specify an
autoplay attribute if you want the video to start when the page finishes loading (but please don't do that, it's annoying):
<div data-id="oX6I6vs1EFs" data-autoplay="yes" class="demo02"></div>
And what about specifying the thumbnail size you want to get? That's what the
thumbnail attribute is for!
<div data-id="oX6I6vs1EFs" data-thumbnail="default" class="demo03"></div>
default and you'll get:
mqdefault and you'll get:
hqdefault and you'll get:
sddefault and you'll get:
maxresdefault and you'll get:
That's simply awesome. But wait!
It's also posible to modify the plugin behaviour if you know what you're doing. Yay!
The videos can be loaded on, say a Magnific Popup box, and all you have to do is create an special handling function as is shown:
<div data-id="oX6I6vs1EFs" data-target="magnificPopup" class="demo04"></div>
This plugin works on IE7+, Firefox and Chrome. Opera should do too, but I don't really care.