WordPress.org

Ready to get started?Download WordPress

Forums

More Fields
Media Library Only Shows 5 Images at a time and not 10 (13 posts)

  1. Adam Capriola
    Member
    Posted 3 years ago #

    I've noticed that when I have this plugin activated, I can only see 5 images at a time in the media library whenever I'm adding a new post. Here are links to what I'm talking about:

    Plugin Activated:
    http://content.screencast.com/users/adum_cap/folders/Jing/media/b423da38-1abe-4a5e-93f2-60247694d1a9/00000015.png

    Plugin De-activated:
    http://content.screencast.com/users/adum_cap/folders/Jing/media/7adc2b07-2506-450d-8398-33a078944f57/00000016.png

    I know this isn't a huge deal, but it bothers me and it seems like it should be a fairly simple fix.

    Does this happen to other people and has anyone come up with a solution?

    Thanks,

    Adam

  2. ClaytonJames
    Member
    Posted 3 years ago #

    I can't help but notice the image count in your first capture (with plugin activated) is 1,539 and the image count in your second capture (with plugin deactivated) is only 86. I find that strange as well. Which is closer to being correct? Maybe another clue for someone to de-bug.

  3. Adam Capriola
    Member
    Posted 3 years ago #

    The pictures are taken from different sites. I was testing different things out and took pics from the separate sites for whatever reason. Either way, site 1 has the plugin activated, site 2 I never installed it.

  4. monodistortion
    Member
    Posted 3 years ago #

    Interesting! I was having this problem but I didn't know what was causing it. I tested out disabling the More Fields plugin and that was the cause. My media library only shows 4 pictures at a time.

  5. monodistortion
    Member
    Posted 3 years ago #

    After a lot of digging I found what is causing the bug (more Fields version 2.0.5.2). I'm not sure what the best way to fix it would be since any change might break the way the plugin is supposed to work. But for the developers-- this is what's causing the bug.

    In the file more-fields-rewrite-object.php there is a line

    add_filter('posts_join', array(&$this, 'query_join'));
    

    that adds a filter called query_join.

    function query_join( $join ) {
    		global $wpdb, $wp_query;
    		if (!is_callable(array($wp_query, 'get'))) return false;
    		if ($key = $wp_query->get('mf_key') || $type = esc_attr($_GET['type'])) {
    			$join .= " LEFT JOIN $wpdb->postmeta as meta ON $wpdb->posts.ID = meta.post_id";
    		}
    		return $join;
    	}
    

    This adds a LEFT JOIN to the normal $wp_query request parameter. This causes each image to show up 3 times in a normal $wp_query.

    Then in the media library iframe the image links are paginated with the function:

    $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']
    ));
    

    My media library should show 18 images split up onto 2 pages but since $wp_query->found_posts is 54 they're split up onto six pages with 4 images on each page.

    =====
    As a temporary fix I'm going to comment out line 16 in more-fields-rewrite-object.php

    //add_filter('posts_join', array(&$this, 'query_join'));
    
  6. Adam Capriola
    Member
    Posted 3 years ago #

    Nice detective work!! I am seeing 10 pics again, I just hope everything remains stable.

  7. mintydog
    Member
    Posted 3 years ago #

    Even stranger, I only saw three items at a time prior to commenting out that line. Thanks for locating it.

    There are many other bugs in this code, none of which existed in their ver 1.x code. Feature bloat always introduces bugs, and they seem to be having a hard time tracking them down.

    Major: In a textarea field, on more than one occasion the field was write-protected, and the values in it were lost when saving the record.

    Minor, but aggravating: The admin css includes code for images using the wrong URL. Add /wp/wp-admin/ in the URLs to resolve it.

  8. kalstrom
    Member
    Plugin Author

    Posted 3 years ago #

    @mintydog: Feature bloat is not the case, I'd say (after all we removed the entire post type functionality for 2.0). But we rewrote the entire engine, which probably is the cause for the problems. But we do rely on bug reports to be able to make fixes.

  9. davemac
    Member
    Posted 3 years ago #

    I am having this issue as well. When I deactivate the More Fields plugin the issue is resolved.

  10. davemac
    Member
    Posted 3 years ago #

    Just wondering when the next version of the plugin is expected? No pressure!

  11. Adam Capriola
    Member
    Posted 2 years ago #

    This still wasn't fixed in the latest plugin update a few days ago. :(

  12. davemac
    Member
    Posted 2 years ago #

    I can confirm it wasn't in the More Fields 2.1 update as well.

    I've updated, and my fix for this issue has been overwritten.

  13. Adam Capriola
    Member
    Posted 2 years ago #

    Try adding this to your functions.php and it should keep it fixed for good:

    remove_filter( 'posts_join', 'query_join' );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic