Created
May 7, 2017 21:14
-
-
Save brucenorton/12cbe0d5f0087a50d66c3dd265ec629f to your computer and use it in GitHub Desktop.
cloudinary PhotoAlbum dynamic context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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