Edit media window

Hello.
Small question about rt-Media.
When I choose to edit a photo, it is in a new window that opens the choices of modification of the image. I think it would be more logical to stay in the same window, especially when the user disconnects. Two windows are open: one to choose to disconnect and another one that always seems to be active … even if the user has choosen to disconnect.
… Just a clarification: it is only when you click “EDITER” on the thumbnails of the photos (see image attached). When I open the image and choose to edit it, no problem, I edit the image in the same window (not a new window).
Thank you.
An idea ? Thank you.

Hello @egabillat,

Opening a media in new tab for editing is the default behavior of a rtMedia plugin.

However, if you want to open media in the same window for editing we can direct you for that.

Copy and paste the code given on the following link into your theme’s functions.php file - https://gist.github.com/mangesh/e8ef1447869c28fc44f61f43053c8c7d

I hope that helps you. Thanks.

Hello and thank you for your help. I already have a modified functions.php file. How to add your code? Here is the contents of my file:

<?php /** * @package WordPress * @subpackage Kleo * @author SeventhQueen * @since Kleo 1.0 */ /** * Kleo Child Theme Functions * Add custom code below */ add_filter('rtmedia_media_tab_position', 'reorder_rtmedia_media_tab_position', 10, 1); function reorder_rtmedia_media_tab_position( $pos ){ return 1; } //* Redirect WordPress to Homepage Upon Logout add_action('wp_logout',create_function('','wp_redirect(home_url());exit();')); add_filter('geodir_login_url','change_geodir_login_url',10,3); function change_geodir_login_url($login_url,$args,$gd_page_id){ //change the url to whatever you want. $login_url = 'http://localhost:8888/register/'; return $login_url; } // Remove admin from the member directory function bpdev_exclude_users($qs=false,$object=false){ $excluded_user='347'; // Id's to remove, separated by comma ohe 347 if($object != 'members' && $object != 'friends')// hide admin to members & friends return $qs; $args=wp_parse_args($qs); if(!empty($args['user_id'])) return $qs; if(!empty($args['exclude'])) $args['exclude'] = $args['exclude'].','.$excluded_user; else $args['exclude'] = $excluded_user; $qs = build_query($args); return $qs; } add_action('bp_ajax_querystring','bpdev_exclude_users',20,2); // once admin is removed, we must recount the members ! function bpfr_hide_get_total_filter($count){ return $count-1; } add_filter('bp_get_total_member_count','bpfr_hide_get_total_filter'); // hide admin's activities from all activity feeds function bpfr_hide_admin_activity( $a, $activities ) { // ... but allow admin to see his activities! if ( is_site_admin() ) return $activities; foreach ( $activities->activities as $key => $activity ) { // ID's to exclude, separated by commas. ID 1 is always the superadmin ohe 347 if ( $activity->user_id == 347 ) { unset( $activities->activities[$key] ); $activities->activity_count = $activities->activity_count-1; $activities->total_activity_count = $activities->total_activity_count-1; $activities->pag_num = $activities->pag_num -1; } } // Renumber the array keys to account for missing items $activities_new = array_values( $activities->activities ); $activities->activities = $activities_new; return $activities; } add_action( 'bp_has_activities', 'bpfr_hide_admin_activity', 10, 2 ); function gde_24hour_times( $times ) { foreach($times as $key=>$val){ $times[$key]=$key; } return $times; } add_filter( 'geodir_event_schedule_times', 'gde_24hour_times' ); __________________ Thank you.

Hello @egabillat,

Just add below code at the end of your existing functions.php file:


// Check if function doest not exists.
if ( ! function_exists( 'rtmedia_wp_footer_add_js_callback' ) ) {
    function rtmedia_wp_footer_add_js_callback() {
        ?>
        <script type="text/javascript">
            jQuery(document).ready(function($) {
                // Event will fire when someone click on edit button of media.
                jQuery( 'body' ).on( 'click', '.rtmedia-gallery-item-actions a:first',function(){
                    var target = jQuery( this ).attr( 'target' );
                    // Checked for the target attribute if it exists or not and is also set to blank.
                    if ( target != 'undefined' && target == '_blank' ) {
                        // Replace the blank target attribute to self target attribute.
                        jQuery( this ).attr( 'target', '_self' );
                    }
                });
            });
        </script>
        <?php
    }
}
add_action( 'wp_footer', 'rtmedia_wp_footer_add_js_callback', 10, 1 );

Please, let me know if you have any doubts. Thanks.

Hi ! Tested… Good job ! Thank you.

Sorry … it only works for the first photo on the left ! For others media edit open a new window. An idea… thank you one more time.

Hello @egabillat,

Oh, okay. I got your issue.

Please, once give this code a try - https://gist.github.com/BhargavBhandari90/6773522ca54a55c56b945ac050383c69

Now, it should work properly :slight_smile:

Thanks

Perfect ! Thank you, merci beaucoup.

You are welcome @egabillat,

I am glad to know that your issue has been fixed.

I am closing this topic now. Please, feel free to create new if you need any assistance in future.

Thanks, Pranali