Add more rows on media picker

I’m trying to add more rows in the media picker modal window. Is there any clean way to achieve doing this ?

Thanks !

Related posts

Leave a Reply

2 comments

  1. my plugin: http://wordpress.org/extend/plugins/mediapicker-more-rows/

    I found a way to fix the pagination

    There is a way you can ‘hook’ into paginate_links. There is no official hook for it, but you can change the $wp_query->found_posts variable.

    What I did here is ‘hooking’ into the paginate_links by abusing the media_upload_mime_type_links filter and setting a new value for $wp_query->found_posts.

    This filter is triggered just before paginate_links is called.

    function set_paginate_limit_mediapicker( $type_links )
    {   
        global $wp_query;       
    
        $new_limit = 30; // set your limit
        $wp_query->found_posts = $wp_query->found_posts / ( $new_limit / 10 );
    
        return $type_links; // not used 
    }   
    add_filter( 'media_upload_mime_type_links', 'set_paginate_limit_mediapicker', 1 );
    

    I have made a WordPress plugin for the complete solution, which you will find in the repository.

    http://wordpress.org/extend/plugins/mediapicker-more-rows/

  2. This works but the big issue is to solve the pagination, because it is completely broken.

    add_filter('post_limits','wpse_33775_add_rows_to_media_library',999,1);
    
    function wpse_33775_add_rows_to_media_library($limits)
    {   
        global $current_screen;
        $tab = isset( $_GET['tab'] ) ? $_GET['tab'] : "type";
    
        if( 'media-upload' != $current_screen->id && 'library' != $tab )
            return $limits;
    
        $my_new_limit = '100';
        $limits = str_replace('10',$my_new_limit,$limits); // replacing the default 10
    
        return $limits;
    }
    

    Is there a way to hook here?

    /*
     * WordPress 3.3.2
     * /wp-admin/includes/media.php
     * line 1828
     *
     */   
    $page_links = paginate_links( array(
        'base' => add_query_arg( 'paged', '%#%' ),
        'format' => '',
        'prev_text' => __('«'),
        'next_text' => __('»'),
        'total' => ceil($wp_query->found_posts / 10),
        'current' => $_GET['paged']
    ));
    
    if ( $page_links )
        echo "<div class='tablenav-pages'>$page_links</div>";