Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
cloudinary PhotoAlbum dynamic context
$(function () {
"use strict";
//The idea is to only load this once someone has filled out the form
let newContext = 'email=new@test.com|credits=Me New Context';
$('.cloudinary-fileupload')
.cloudinary_fileupload({
dropZone: '#direct_upload',
context: newContext,
start: function () {
$('.status_value').text('Starting direct upload...');
},
progress: function () {
$('.status_value').text('Uploading...');
}
})
.bind('fileuploadprogress', function(e, data) {
$('.progress_bar').css('width', Math.round((data.loaded * 100.0) / data.total) + '%');
})
.on('cloudinarydone', function (e, data) {
$('.status_value').text('Idle');
$.post('upload_complete.php', data.result);
var info = $('<div class="uploaded_info"/>');
$(info).append($('<div class="data"/>').append(prettydump(data.result)));
$(info).append($('<div class="image"/>').append(
$.cloudinary.image(data.result.public_id, {
format: data.result.format, width: 450, height: 450, crop: "fill"
})
));
$('.uploaded_info_holder').append(info);
});
$('.cloudinary-fileupload').cloudinary_fileupload('option', 'formData').context = newContext;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment