I’m using the uploader shortcode and created my own child theme template for it. I wanted to display the member’s remaining storage usage, using mpp_display_space_usage(), but have it refresh for each image the user uploads. That way the user knows how much space they have left, for every image they upload.
The solution I came up with is to run a mutation observer that watches the div where the new images get appended (#mpp-uploaded-media-list-shortcode), and fire an ajax GET to retrigger mpp_display_space_usage() whenever mutation is detected. It is working perfect. But, I’m just wondering if there is a more direct method you guys would recommend for this purpose, like some preexisting event trigger I could tap into, instead of manually observing for mutations on that div.
Anyways, I’m curious to know your thoughts whether my method is the best one for this. Let me know if anyone wants me to post up my working code using the mutation observer approach and I’ll be happy to share.
Thank you for posting.
tough the uploader fires events for queuing, progress, and upload complete, they are not available on public object to allow binding.
I will add some other way to emit the event and make it easy to hook to.
Will message you here after I add it.
Thanks Brajesh! That would be awesome, but please only worry about this if you are interested and think it’d benefit other users too, and you have time. The method I’m using is working, so, no need for a special addition just on my behalf. Thanks again for the helpful info.
You must be logged in to reply to this topic.