WordPress’ Gallery feature display full images instead of thumbs

I’ve encountered an issue with recent version of WordPress which I believe I have found a fix for.  I’m a big fan of the new gallery abilities that have been built into the 2.5 and 2.6 versions of WordPress.  To me, they easily allow for uploading and posting photo galleries and work great – at least until recently.  Something in the underlying code broke with one of the 2.5 releases and has yet to be fixed.

I had setup a WordPress site for a friend’s church.  It works well and she wanted to be able to post photos from their events and get-togethers.  So, I logically upgraded her to the latest, greatest WordPress to make use of the gallery feature.  But, then the problem occurred.  After using the gallery shortcode, the images displayed were not the thumbnail images, but rather the fullsize images.  And, no setting seemed to fix this problem.

After getting fairly frusterated with the problem last night, I decided to delve into the code and trace through it to find the cause.  After tracing through many functions, I located the problem in the wp_get_attachment_metadata function.  This function was invoked but returned no usable information for the attachment (image, movie, etc.).  Now, this is where I stopped, because I got the desired effect.  The function definition is the following:

function wp_get_attachment_metadata( $post_id, $unfiltered = false ) {

A conditional statement later in the function looks to the $unfiltered variable.  Because it was defaulting to false, it never returned the array of values that it had retrieved.  It instead attempted to “apply_filters” to the array.  The apply_filters apparently did not work correctly.  So, a simple change in the declaration from false to true fixes our thumbnail image problem in WordPress 2.6.2 and 2.6.3.

The wp_get_attachment_metadata function is located in /wp-includes/post.php.   I hope that maybe this will help someone else.  AND, I will be looking into the apply_filters function more to see what its actually supposed to be doing there…

Tags: , ,

 

About the Post

Author Information

Philip is a IT solutions engineer working for AmWINS Group, Inc., an insurance brokerage firm in Charlotte, NC. With a focus on data center technologies, he has built a career helping his customers and his employers deploy better IT solutions to solve their problems. Philip holds certifications in VMware and Microsoft technologies and he is a technical jack of all trades that is passionate about IT infrastructure and all things Apple. He's a part-time blogger and author here at Techazine.com.

One Response to “WordPress’ Gallery feature display full images instead of thumbs”

  1. nice article bro, thx..

    November 24, 2008 at 7:25 am Reply

Leave a Reply

%d bloggers like this: