WordPress 3.5 media_order Issue Affects Custom Galleries
The revamped Add Media interface in WordPress 3.5 improves a great many things about media management. It’s fantastic and thanks go out to the team for all the hard work!
Unfortunately, the removal of a visible menu order field and the associated “Sort by Ascending / Descending” links has created an issue that affects some plugins and themes.
For instance, I often code templates that detect all images attached to a post and display them in a slideshow. In these cases I rely on the menu_order field to set the image order. Here’s a line I use often:
I’ll walk through the steps that illuminate the issue. First we’ll create a new post and upload a bunch of images to it. Using the “Uploaded to this post” filter, they appear to be in the correct order…
When we look in the DB, we see that their menu orders are actually all “0”. As we will see, this has some funny effects.
We close the Media Upload window and continue our work. When we return to the Media Upload screen, the image order appears to have been reversed.
Now, at this point there’s been no actual change in the DB. But it’s not unreasonable for the user to be a bit confused, and to manually make a change to the order. Here I’ve dragged the 01 image to the first spot:
When I do this, WordPress finally assigns a non-zero order to all of these images. Unfortunately, the order being assigned is the same (backwards) order that we are seeing via the interface.
As you can see, “image02” has been assigned a menu order of 25. To properly reorder the images involves manually dragging and dropping, which can be quite onerous with large image sets.
Posted January 2013