UploadCare doesn't load image in dialog

219 Views Asked by At

I expect the UploadCare dialog to open after clicking MyButton, showing the Twitter logo, but it doesn't. Why not?

$('#MyButton').on('click', function() {
    uploadcare.openDialog('https://g.twimg.com/About_logoUsage.png');
    return false;
});
1

There are 1 best solutions below

0
On BEST ANSWER

You need to pass a file object as an argument to openDialog method. You can obtain the file object by calling uploadcare.fileFrom method:

// Pre-load an image from arbitrary URL,
// and open Uploadcare file upload dialog
$('#MyButton').on('click', function() {
    var file = uploadcare.fileFrom('url', 'https://g.twimg.com/About_logoUsage.png');
    uploadcare.openDialog(file);
    return false;
});