Created
December 3, 2011 04:50
-
-
Save gudbergur/1426081 to your computer and use it in GitHub Desktop.
Very bare Embed.ly plugin for TinyMCE
This file contains hidden or 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
// Requirements: jQuery | |
// Installation: Add this to your tinyMCE.init, put in your button image and your Embed.ly key and you're good to go | |
// This is just a very simple embed.ly button cause Google turned up squat. | |
setup : function(ed) { | |
ed.addButton('myembedly', { | |
title : 'Embed.ly', | |
image : 'BUTTON IMAGE', | |
onclick : function() { | |
var url = prompt("Enter URL to embed"); | |
if (url == null) return; | |
$.ajax({ | |
url:"http://api.embed.ly/1/oembed?key=YOUR KEY&maxwidth=500&url="+encodeURIComponent(url), | |
dataType: 'jsonp', | |
success: (function(ed){ | |
return function(data) { | |
if (data.html != undefined) { | |
ed.focus(); | |
ed.selection.setContent(data.html); | |
} else { | |
alert('Couldn\'t find anything to embed') | |
} | |
} | |
})(ed) | |
}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment