Call jQuery on image upload

I’m currently using jQuery Masonry, however I’m having an issue when the user uploads an image it breaks the Masonry plugin, is there a way I can call Masonry to update when the upload Ajax adds the image?

  • Sythen

Hi Sythen,

Use this js code in your theme. It will be called when all the files will be uploaded.

rtMediaHook.register( 'rtmedia_js_after_files_uploaded', function() {  
        // your code here  

Hey there, thank you for pointing me in the right direction, .Register unfortunately overrides the actual action of rtMedia adding the image to the list, I however want it to do that, but after it has, then refresh Masonry.

I’ve tried searching for an rtMediaHook that gets called after rtmedia_js_after_files_uploaded, but can’t seem to find one.

Is there a way I can call masonry on rtmedia_js_after_files_uploaded without overriding it’s current functions?

  • Scott.

Hi Scott,
Check file /app/assets/js/rtMedia.backbone.js. line no. 292 for rtmedia_js_after_files_uploaded.

You need to call masonry reload method in the code I gave you above. Also, try it in setTimeout function.