Media Library Widget
I have setup the Media Library Widget - and are able to upload images.
But I need these images to be transformed using a upload preset. The upload preset works if I'm using the upload widget.
Current code for the "Media Library Widget " (Upload preset does not work)
===================================================================
window.ml = cloudinary.createMediaLibrary({
cloud_name: '@ViewBag.Cloudname',
api_key: '@ViewBag.apiKey',
username: '@ViewBag.user',
timestamp: '@ViewBag.unixTimestamp',
signature: '@ViewBag.signature',
uploadPreset: 'ugzdn0txw',
button_class: 'myBtn',
button_caption: 'Select Image or Video',
}, {
insertHandler: function (data) {
console.log("Hello World");
data.assets.forEach(asset => {
console.log("Inserted asset:",
JSON.stringify(asset, null, 2))
})
}
},
document.getElementById("open-btn")
)
Current code for the "Upload Widget " (Upload preset works)
===================================================================
var myWidget = cloudinary.createUploadWidget({
cloudName: '@ViewBag.Cloudname',
uploadPreset: 'ugzdn0tx'
}, (error, result) => {
if (!error && result && result.event === "success") {
console.log('Done! Here is the image info: ', result.info);
}
}
)
-
Hi,
The `uploadPreset` is not relevant when calling createMediaLibrary (and therefore is ignored).
When uploading from the media library widget the Media Library Upload Preset is used.
The Media Library Upload Preset can be defined in Media Library -> Settings -> Upload (bottom of page). This will be applied for all resources uploaded from the Media Library UI.
Hope this helps,
Dana.
0
Post is closed for comments.
Comments
1 comment