Rtmedia uploader question on thumbnails (previews)

Hello,

I have a question concerning rtmedia uploader, when we select files (images) and when they are displayed (before the upload).
I added a button under the uploader. I would like it to “activate” only if image previews are ready.
For example, if I click at this moment, when previews are still not ready :

It would wait until all photos are ready:

and then for example we can access the page generated by the click on the button.
Is there a hook or something to know if the thumbnails are ready/displayed?

Thanks,

Marine

Hello @marine,

Could you please try using the filter rtmedia_media_thumb?

Here is the file where you can find the filter - https://github.com/rtMediaWP/rtMedia/blob/4476ba404c42e1361c1c47db47d68dedbca135a2/app/main/controllers/template/rtmedia-functions.php#L687

Thanks

Hello @marine,

The above filter will be used to change the src of the media and won’t work for you. To make your job done, you will need to play with some JavaScript events. We tried creating a sample code for you for this.

You can try following below steps:

  1. Make your button by default display:none by css.

  2. Add the code below into your theme’s functions.php file.

/**
 * Do stuff after file added to uploader.
 */
function rtmc_call_after_files_added() {
    ?>
    <script>

        if( typeof rtMediaHook == "object" ){   // check if rtMediaHook defined or not
            rtMediaHook.register(
                'rtmedia_js_after_files_added', // hook id here
                function ( args ) { // your function here
                    jQuery( '.your_button_class' ).show(); // add your button class here
                }
            );
        }


    </script>
    <?php
}
add_action( 'wp_footer', 'rtmc_call_after_files_added' );

I hope this helps you. Thanks.