var imgur = new Imgur({
clientid: '',
callback: feedback
});
var d = new FormData;
d.append("image", "https://cdn-images-1.medium.com/max/316/1*LUfpOf7teWvPdIPTBmYciA.png"),
imgur.post(imgur.endpoint, d, function(a) {
document.body.classList.remove("busy"),
"function" == typeof this.callback && thisimgur.callback.call(this, a)
}
.bind(this));
Puedes ver un feo ejemplo, y por desgracia no funcional (requiere autentificación)ejemplo funcionar en es siguiente código implementando un formulario de envió fuera del dropzone facilitado por la librería.
var feedback = function(res) {
if (res.success === true) {
var get_link = res.data.link.replace(/^http:\/\//i, 'https://');
document.querySelector('.status').classList.add('bg-success');
document.querySelector('.status').innerHTML =
'Image : ' + '<br><input class="image-url" value=\"' + get_link + '\"/>' + '<img class="img" alt="Imgur-Upload" src=\"' + get_link + '\"/>';
}
};
(function() {
var imgur = new Imgur({
clientid: 'cc86a8de0e7c459',
callback: feedback
});
function onSubmit(event, form) {
if (event) { event.preventDefault(); }
var d = new FormData;
d.append("image", this.image.value);
//debugger;
imgur.post(imgur.endpoint, d, function(a) {
document.body.classList.remove("busy"),
"function" == typeof this.callback && thisimgur.callback.call(this, a)
}
.bind(this));
}
var form = document.getElementById('linkform');
form.addEventListener('submit', onSubmit, false);
form.submit = onSubmit;
})();
#linkform > * {width: 100%; margin: 2px}
<link href="https://cdn.rawgit.com/pinceladasdaweb/imgur/3ee965f9/src/imgur.css" rel="stylesheet"/>
<script src="https://cdn.rawgit.com/pinceladasdaweb/imgur/3ee965f9/src/imgur.js"></script>
<body>
<div class="title">
<h1>Imgur Upload API</h1>
<p>es.stackoverflow.com @dperezv.com</p>
</div>
<div>
<form id="linkform">
<input type="text" name="image" value="https://cdn-images-1.medium.com/max/316/1*LUfpOf7teWvPdIPTBmYciA.png" />
<button type="submit">Subir a imgur</button>
</form><br/>
</div>
<div class="dropzone">
<div class="info"></div>
</div>
<div class="status">
</div>
</body>