4

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

Thanks !

2
  • You can upload multiple files by ctrl+click. Does that resolve your issue?
    – GavinR
    Nov 16, 2011 at 1:30
  • Thanks but it's not the point ;) I want to be able to visualize more than 10 uploaded images by page.
    – Kaaviar
    Nov 16, 2011 at 23:44

2 Answers 2

2

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
  • Amazing, tschutter! Pity is that I did put a bounty of 100 points on this question that ended some days ago...
    – brasofilo
    Jun 25, 2012 at 17:10
  • That's ok, glad I could be of help!
    – tschutter
    Jun 26, 2012 at 7:36
0

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>";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.