WordPress Reorder Gallery Plugin

Posted by Aaron D. Campbell | Thursday, May 15th, 2008
, ,

When I talked about my first impressions of WordPress 2.5 I mentioned the new shortcodes. Then I went more in depth, as I explained exactly what WordPress Shortcodes were, and how they worked. However, neither time did I mention that there is a shortcode that is built into WordPress (no plugin needed). It’s the gallery shortcode. You can upload images to the post, and then choose to “Insert gallery into post” and it will add a [gallery] tag to your post, which will be replaced with the image gallery when people view it. The problem? Images are stuck in whatever order you upload them in.

Drag and drop image reordering in WordPressThis all works great for most people, but I had a client, LifeStory Photography, that wanted to use a flip-book style album to display her photography. The problem was that she needed to regularly reorder the images in her gallery (yes, that flipbook uses the [gallery] shortcode and modifies how it works), and there is no way to re-order the images. This plugin solves that. There is a way to manually set the order using a number (lower is near the beginning, higher is toward the end) in the image details, or you can simply drag and drop to order the images how you want them to appear.

Related Posts

42 Comments to WordPress Reorder Gallery Plugin

Infoclipper
May 15, 2008

Cool plugin– definitely downloading it now; thanks!

Quick (unrelated) question: do you have a source for that Flipbook plugin? After looking at your client’s site, that looks perfect for an idea I had in mind for my own!

Aaron D. Campbell
May 15, 2008

Infoclipper: I didn’t develop the page flip component, it is the property of Flipping Book (non-affiliate link). I’m trying to talk to them now to see if I can purchase a license that will let me distribute the .swf that uses their component with my plugin. Until then, you can purchase the component from them, and send me the details. When I see that you have a valid license, I’d be happy to give you the plugin that goes along with it.

Greg Medding
May 17, 2008

This plugin sounds very useful, but I am unable to activate it. When I hit the activate button I get an error like this:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/meddingn/public_html/~greg/blog/wp-content/plugins/reorder-gallery/reorder-gallery.php on line 51

Do you have any idea what might be the problem? This happened with both version 1.0.0 and version 0.1.0.

Aaron D. Campbell
May 17, 2008

Greg: It looks like you don’t have PHP 5+. All my plugins require PHP5. This is stated in the readme, and the description on the WordPress.org site, but I somehow forgot to put that in the description that shows in your plugin panel this time. I’ll fix that right away, but in order for you to use this plugin you’ll have to ask your host to change you over to PHP 5.

Matt
May 17, 2008

This would be pretty cool functionality for core WP — would you be interested in having it included?

Aaron D. Campbell
May 17, 2008

Matt: Sure, I’d be happy to. I opened a ticket in trac to handle it. I’ll put a patch up real soon. If you get a chance, stop by and chime in on what milestone you would like to integrate it into.

[...] WordPress Reorder Gallery Plugin · Xavisys (tags: @inbox) [...]

Mr Papa
May 26, 2008

Aaron,

Very nice, but running into an issue or maybe its a limitation. With the plugin enabled, when I go edit a gallery (via media uploader) and want to change the description of a particular image in that gallery, I am unable to click in the description textarea or any other input box. I am however able to tab down to that box after clicking somewher in the open image.

I tried to disable my plugins to see if I had a conflict, but still had same effect.

Is this a limitation or just something with my environment.

Thanks…

Blake
May 29, 2008

This plugin doesn’t work at all for me. I can reorder the images while editing the page, but it has no effect on how the gallery displays. It still displays in the order in which the images were uploaded. I also have the same problem as Mr Papa in that I can’t change the description of the images with this plugin enabled. Thirdly, I have the gallery embedded in a page, and when I add images to it, it creates an unpublished post for each image with the tile of the image as the title of the post. It is really strange. I like the idea of this plugin, but it is just too buggy and doesn’t work. BTW, I am using the latest WP 2.5.1.

Tom Pimental
May 30, 2008

Very impressive. Nice work. You’ve made my wife (and her new WP powered gallery) very happy. Looking forward to 2.6.

Aaron D. Campbell
May 30, 2008

Sorry for the slow replies, the work load here has been steadily increasing.

Mr Papa and Blake: What browser/operating system are you guys using (please be as specific as possible)? I’m not seeing the issue on any of the sites that I currently have using the plugin. The code has already been integrated into WordPress, so the functionality will be included in 2.6. If a bug exists, I’d like to squash it before 2.6 comes out.

Tom: I’m glad you like it!

Mr Papa
May 31, 2008

Aaron,

browser is FF 2.0.0.14 but see same issue with IE 7

for os, I assume you mean on the server… its linux, fedora core 4 (or windows xp with sp3 if interested in my machine)

I have seen it on all sites I have tried, but thats expected since they are all on same box and viewed on same pc :wink:

I could probably set you up with a temp account if you want to have a look…

Mr Papa
May 31, 2008

actually, just retested, at least on my local wamp install, and its working fine in IE 7… but FF is still no go..

Aaron D. Campbell
May 31, 2008

Mr Papa was nice enough to lend me a login to his site, and go over the error with me. It turned out to be a glitch in the interface plugin for jQuery. The workaround is to make the filename a “handle” to drag the image by. Version 1.0.1 has been released to fix this, and should be available for download in about 15 minutes. If you are experiencing any problems with being able to click to give focus to an input field in the image details, please upgrade to version 1.0.1.

The code that was added to WordPress for the 2.6 release was/is not affected by this bug, because the WordPress team is discontinuing the use of the interface plugin, in favor of jQuery UI (which seems to work fine)

craig
June 1, 2008

thanks for updating the plugin. I was having the same problem as stated above. Nice job!

Mr Papa
June 8, 2008

see something odd Aaron… on the site you helped debug the interface plugin issue, I am now having issue reordering the images in a gallery. The plugin seems to work fine. I can drag and drop and move images around. the order number gets set accordingly, but as soon as I save my changes, the order reverts back to the original order. The order number stays where they were when I reordered, but they dont display in the flash uploader or on the site in that order…

any thoughts?

Zack Katz
June 9, 2008

Thank you! You just made me happy having realized that I needed this exact functionality. I’m not using the [gallery] shortcode, but instead using a custom query for getting all the images attached to a post:


"SELECT ID, post_title, post_parent, menu_order FROM " . $wpdb->posts . "
WHERE post_parent = '" . $post->ID . "'
AND `post_type` = 'attachment'
AND `post_mime_type` LIKE 'imag%'
ORDER BY `menu_order`"; // this is thanks to your plugin, I believe?

Aaron D. Campbell
June 9, 2008

Mr Papa: It looks like it’s a problem stemming from #6731 which has been fixed both in trunk as well as the 2.5 branch. This basically means that it should be fixed in the next WordPress release (2.5.2), which should be out in the next week or two.

Zack: I’m glad it could help you out. When 2.6 comes out, this feature will be built in, and better than ever.

Mr Papa
June 9, 2008

Thanks Aaron…

I will try applying the patch and seeing if it helps… but a little worried that they dont display in the right order on the actual gallery page either… will have to double check that its using menu order too

Mr Papa
June 9, 2008

Aaron,

From what I can tell, it was an issue in 2.5 but was fixed in 2.5.1… Its certainly in the 2.5.1 that I am running…

Blake Middleton
June 9, 2008

Aaron, I have upgraded the plugin but still the gallery is not being displayed in the order I set. I am using FF and Safari. The other bug of not being able to click in the text box is fixed, but the main function of the plug-in still doesn’t work for me. Also, the first thumbnail in the gallery re-order window never shows up for me. Thanks.

Mr Papa
June 9, 2008

Personally, I think there is an issue with wp core here, but could be wrong… the get_posts() function generates the query in lines 465 - 479. The generated query is


SELECT DISTINCT * FROM wp_posts WHERE 1=1 AND post_type = 'attachment' AND wp_posts.post_parent = 54 AND (post_mime_type LIKE 'image/%') GROUP BY wp_posts.ID ORDER BY menu_order ASC, ID ASC

Why in the heck is that GROUP BY in there… that seems to screw up the returned results and the posts are not returned in menu order. Removing that GROUP BY clause allows the results to be returned in menu order.

Doesnt this violate the MySQL Single-Value Rule?

Now, I am definitely not an expert here but I really dont understand what the GROUP BY is for…

Now, this may also be OBE with 2.6 with this ticket since they completely rewrote the routine. But wondering what 2.5.2 does?

Am I missing something here and just wrong?

Mr Papa
June 9, 2008

I should mention that removing that GROUP BY clause from the query fixes both the media loader (with your plugin) and the page display so the ORDER BY clause is actually used to sort.

Mr Papa
June 11, 2008

This might be an issue depending on page depth… have one site where its not issue, but the gallery/image pages are essentially the page parent…

however, if I have say a site gallery page, then with album pages, and each album may have sub-albums, it breaks down…

still researching, but the “patch” in my previous comment seems to work for the galleries no matter the page depth…

Amber
June 17, 2008

This is just what I need… but I can’t activate it. I get the following fatal error:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /home/rebelloh/public_html/wp-content/plugins/reorder-gallery/reorder-gallery.php on line 54

I checked the php version is 5.2.5

Aaron D. Campbell
June 17, 2008

Amber: How did you check your PHP version? If you checked with your host, many offer both PHP 4 & 5, and you have to specify if you want to use PHP 5 (4 is often the default). Try creating a file with the contents:

< ?php phpinfo(); ?>

Name it whatever you want (like phpinfo.php) and upload it to your site. Use a browser to view that file, and it will give you all sorts of details about your PHP, including which version is actually executing the file.

Amber
June 18, 2008

Aaron: You were right the cpanel said 5 but they are running 4.4.8. I was able to add a AddHandler to my .htaccess file so now I have it activated, but I am having the same problem as Blake. It is not showing in the correct order.

Am I reading this right that I need to modify to core files? And if so, can you tell me exactly which one to edit. This is making me nervous, but I need this fix for a client ASAP, I can’t wait for 2.6 to be released.

Amber
June 30, 2008

Please respond with the code that I need to change. I have deleted the images and reuploaded them and they are still showing in the wrong order.

Aaron D. Campbell
June 30, 2008

Amber: It’s a problem stemming from #6731 which has been fixed both in trunk as well as the 2.5 branch. This basically means that it should be fixed in the next WordPress release (2.5.2), and in 2.6 which should be released between July 7th and July 14th.

Amber
July 1, 2008

Thank you. I will be looking for it.

Chuck
July 8, 2008

It seems that the lightbox gallery plugin doesnt do any sorting. Can anybody suggest where to look and what to add to lightbox to use this re-ordering?

Thanks,

Chuck

alex
July 9, 2008

Hello, I am trying your plugin now.
I wonder if it’s possible, apart from reordering the slides, to prevent some of the images from displaying? Because the gallery shortcode by default displays all the uploaded images, it would be useful to be able to choose some that are actually not part of the gallery.

Aaron D. Campbell
July 9, 2008

alex: It’s possible, but not with this plugin. I don’t know of any that currently exist to do that, so you may need something custom.

jerome
July 9, 2008

I would like to use this plugin, but my server is running PHP 4.4.4. Will the WordPress 2.5.2 or 2.6 integrated version also require PHP 5 to work?

Aaron D. Campbell
July 10, 2008

jerome: No, 2.6 (which was delayed and should release on 07/14/2008) will not require PHP 5.

Will W
July 10, 2008

THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU!

A million thanks - or at least twenty. That works great.

Chuck
July 14, 2008

Can somebody give me a pointer on what I can add to the order_by clause of lightbox.php to take advantage of this plugin? currently it isnt sorting.

Chuck

[...] default, you can’t rearrange the order of the gallery images. However, the WordPress Gallery Reorder Plugin allows you to easily do [...]

Jessie Angel
September 3, 2008

It didn’t work for me… I tried to re-order items, and saved all, but it didn’t change them :(

Leonaut.com
September 8, 2008

WordPress Reorder Gallery Plugin…

Gives you the ability to simply drag and drop to reorganize your images how you want them to appear in your gallery. If drag and drop isn’t your thing, it also adds an “Order” field to the images in your gallery, much like pages have, which allows y…

Aaron D. Campbell
September 8, 2008

At this point, you should just upgrade to WordPress 2.6, which has this included.

Цой
October 1, 2008

Можно и поспорить по этому вопросу, ведь только в споре рождается истина. :)

Leave a comment