Skip to content

Instantly share code, notes, and snippets.

@leefish
Created October 9, 2015 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leefish/fb57be591bf9c58b1402 to your computer and use it in GitHub Desktop.
Save leefish/fb57be591bf9c58b1402 to your computer and use it in GitHub Desktop.
HTTPS imgur using sceditor and mybb
/* 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