Skip to content

Instantly share code, notes, and snippets.

@jtrain
Last active December 17, 2015 13:39
Show Gist options
  • Save jtrain/5619278 to your computer and use it in GitHub Desktop.
Save jtrain/5619278 to your computer and use it in GitHub Desktop.
Embedly's iframe in a fluid layout using inline replace.
(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});
@jtrain
Copy link
Author

jtrain commented May 21, 2013

An example of the script in action here:

http://jerviswhitley.com/embedly-fluid-iframe-video/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment