BuddyDev

Search

Small idea and my solution: refreshing storage usage in uploader template

  • Participant
    Level: Initiated
    Posts: 14
    Andy on #9868

    Hi guys,

    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.

    Thanks,
    Andy

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #9887

    Hi Andy,
    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.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 14
    Andy on #9903

    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.

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #9905

    Thank you Andy.

    I will certainly add it but since you have given me some time, I will leave it for 1.1.6(1.1.5 should come today/tomorrow). It will be certainly helpful for others too.

    Thank you
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved