WordPress.org

Ready to get started?Download WordPress

Forums

Media Library Categories
[resolved] 40% performance hit (6 posts)

  1. Andrzej
    Member
    Posted 2 years ago #

    P3 (Plugin Performance Profiler) scan shows that a huge percentage of page load time is used by Media Library Categories plugin. Is there a recommended method for using media categories while maximizing performance?

    http://wordpress.org/extend/plugins/media-library-categories/

  2. Andrzej
    Member
    Posted 2 years ago #

    Ok, I found another thread addressing this issue - Sitewide slowdown.

    The mc() mod did not help but the other SHOW COLUMNS and if empty() did reduce the plugin load time from 1.3sec to 0.04sec

    Is there any risk of these mods breaking desired functionality - possibly page level scripts that display media by category?

  3. Andrzej
    Member
    Posted 2 years ago #

    Site operation appears stable and snappier with the above mods.

  4. jasonsteeghs
    Member
    Posted 2 years ago #

    Hi Awoz,
    Can you please explain what you mean in the second post:
    "...the other SHOW COLUMNS and if empty() did reduce the plugin load time..."
    I'm was forced to turn off this plug-in due to load times, but if there's a way to resolve this, it would be very helpful!
    Thanks!
    Jason

  5. Andrzej
    Member
    Posted 2 years ago #

    Hello Jason,

    From the "Sitewide slowdown" post, I came up with this solution. Edit the "media-categories.php" file and make these changes.

    at line 153, replace:

    $query = "
    SELECT COUNT(*) FROM information_schema.COLUMNS
    WHERE
    TABLE_NAME = '$wpdb->terms'
    AND COLUMN_NAME = 'term_order';
    ";

    with:

    $query = "
    SHOW COLUMNS FROM $wpdb->terms LIKE 'term_order';
    ";

    at line 167, replace:

    if($row_count==0)

    with:

    if(empty($row_count))

    Hope it works for you as well as it does for me.

  6. randalny
    Member
    Posted 2 years ago #

    Works very well for me. I was wondering why my site suddenly crawled.

    Also, the sort page is still not working, so the "Sort Media Items" links are essentially useless. In order to make these nice listing pages at least a bit useful (even without the sorting capability) I hacked sort.php to allow linking to view and edit the images:

    (Starting on line 147 replace whole if statement with)

    if ($results){
    		$num_rows = count($results);
    		if($num_rows>0)
    		{
    			$i=1;
    			$bgcol="";
    			foreach ( $results as $row )
     { 
    
    				$label = $row->post_title;
    				$id = $row->ID;
    				$fileUrl = $row->guid;
    				$mime = $row->post_mime_type;
    
    				$thumbnailSize = 'thumbnail';
    				$thumb = wp_get_attachment_image_src( $id, 'thumbnail' );
    				$full = wp_get_attachment_image_src( $id, 'full' ); //--- fix to view full images RHD
    				$editlink = "media.php?attachment_id=".$id."&action=edit";  //--- fix to link to image edit RHD
    
    				$currentOrderBy = $row->term_order;
    
    				if($mime=='image/jpeg')
    				{
    					print "
    					<tr id='$id' style='background-color:$bgcol'>
    						<td>$id</td>
    						<td><a href='".$editlink."' title='Edit Image'>$label</a></td>
    						<td><a href='".$full[0]."' title='View Full-Sized Image'><img src='".$thumb[0]."' /></a></td>
    					</tr>";
    				}
    				else
    				{
    					print "
    					<tr id='$id' style='background-color:$bgcol'>
    						<td>$id</td>
    						<td>".$fileUrl."</td>
    					</tr>";
    				}
    
    				$i+=1;
    
    			}
    		}
    		}

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic