May 15th, 2008 WordPress Reorder Gallery Plugin
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.
This 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.
Infoclipper Says:
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 Says:
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 Says:
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 51Do 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 Says:
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 Says:
This would be pretty cool functionality for core WP — would you be interested in having it included?
Aaron D. Campbell Says:
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.
Can you spell cacophony? » links for 2008-05-19 Says:
[...] WordPress Reorder Gallery Plugin · Xavisys (tags: @inbox) [...]
Mr Papa Says:
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 Says:
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 Says:
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 Says:
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 Says:
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
I could probably set you up with a temp account if you want to have a look…
Mr Papa Says:
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 Says:
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 Says:
thanks for updating the plugin. I was having the same problem as stated above. Nice job!
Mr Papa Says:
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 Says:
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 Says:
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 Says:
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 Says:
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 Says:
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 Says:
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 Says:
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 Says:
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 Says:
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 Says:
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 Says:
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 Says:
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 Says:
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 Says:
Thank you. I will be looking for it.