I'm trying to implement Cloudinary into my Backbone Marionette Rails app. I'm able to upload and display images just fine in one view. However in a second view, the images only display if I've first visited/seen the images in the first view. If I manually refresh the second view I get a Uncaught Unknown cloud_name error.
The weird thing is I'm displaying the images exactly the same way in the onRender function. I've tried logging out the models and the image property is still set properly.
Any ideas what might be going on?
#the onRender function I am using in both views
onRender: ->
if @model.get('image')
@$('.thumbnails').append($.cloudinary.image(@model.get('image'), { format: 'png', width: 150, height: 100, crop: 'thumb', gravity: 'face', effect: 'saturation:50' } ))
#how I create set the image property on the model:
@$('.upload_field').unsigned_cloudinary_upload(PRIVATE, { cloud_name: 'PRIVATE'}, { multiple: true }).bind('cloudinarydone', (e, data) =>
$('.thumbnails').empty().append($.cloudinary.image(data.result.public_id, { format: 'png', width: 150, height: 100, crop: 'thumb', gravity: 'face', effect: 'saturation:50' } ))
@model.set(image: data.result.public_id.toString())
).bind('cloudinaryprogress', (e, data) ->
$('.progress_bar').css('width', Math.round((data.loaded * 100.0) / data.total) + '%'))
Turns out I was missing the global config from the second view's controller:
$.cloudinary.config({ cloud_name: PRIVATE, api_key: PRIVATE})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With