Last active
December 17, 2015 13:39
-
-
Save jtrain/5619278 to your computer and use it in GitHub Desktop.
Embedly's iframe in a fluid layout using inline replace.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
window.embedlyFluid = function(selector, key, options) { | |
$(selector).each(function() { | |
// set the video to the width of the parent container | |
var width = $(this).parent().width(); | |
defaults = { | |
secure: true | |
, frame: true | |
, maxwidth: width | |
} | |
query = $.extend({}, defaults, options); | |
$(this).embedly({ | |
key: key | |
, query: query | |
}); | |
}); | |
}; | |
})(); | |
// here is how to use embedlyFluid. | |
embedlyFluid('.document a', EMBEDLY_KEY); | |
// adding auto-play | |
embedlyFluid('.document a', EMBEDLY_KEY, {autoplay: true}); | |
// autoplay and disable embedly iframes | |
embedlyFluid('.document a', EMBEDLY_KEY, {autoplay: true, frame: false}); | |
// finally forcing your own maxwidth. | |
embedlyFluid('.document a', EMBEDLY_KEY, {maxwidth: 200}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An example of the script in action here:
http://jerviswhitley.com/embedly-fluid-iframe-video/