Javascript Media Library Widget
Hello,
Thank you for your great service.
When i create a simple html page with the code provided in the examples at https://cloudinary.com/documentation/media_library_widget , the widget displays correctly but my callback insertHandler never gets called.
Another issue I get is that when I click the close button of the modal dialog nothing happens.
The page is hosted as a static file in a nodejs server, here is the full page code (with censored cloud_name, api_key and username):
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<button id="open-btn"></button>
<script src="https://media-library.cloudinary.com/global/all.js"></script>
<script type="text/javascript">
window.ml = cloudinary.createMediaLibrary({
cloud_name: 'xxx',
api_key: 'xxx',
username: 'xxx@example.com',
button_class: 'myBtn',
button_caption: 'Select Image or Video',
insert_transformation: true,
}, {
insertHandler: function (data) {
console.log("Hello World");
data.assets.forEach(asset => { console.log("Inserted asset:",
JSON.stringify(asset, null, 2)) })
}
},
document.getElementById("open-btn")
)
</script>
</body>
</html>
-
Hi Roee,
Thank you for the support, the close button now works correctly.
The problem now is that when i select one or more images it doesn't appear the orange "Insert" button at the top of the popup, the button that should be clicked to trigger my insertHandler callback. (screenshot attached)
Am i doing something wrong?
-
Hi Lorenzo,
I couldn't reproduce the issue on my end. Please open a support ticket at support@cloudinary.com, share your code and ways to reproduce and we'll be glad to investigate this further.
Post is closed for comments.
Comments
4 comments