Created
October 9, 2015 10:51
-
-
Save leefish/fb57be591bf9c58b1402 to your computer and use it in GitHub Desktop.
HTTPS imgur using sceditor and mybb
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
/* Lets build a FormData object*/ | |
var fd = new FormData(); // I wrote about it: https://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/ | |
fd.append("image", file); // Append the file | |
var xhr = new XMLHttpRequest(); // Create the XHR (Cross-Domain XHR FTW!!!) Thank you sooooo much imgur.com | |
xhr.open("POST", "https://api.imgur.com/3/image.json"); // Boooom! | |
xhr.onload = function() { | |
var link = JSON.parse(xhr.responseText).data.link; | |
var linkNoProtocol = link.replace(/^https?\:\/\//i, ""); | |
var code = '[img]' +'https://'+ linkNoProtocol + '[/img]'; | |
$('#message, #signature, textarea[name*="value"]').data('sceditor').insert(code); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment