Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#22607 closed defect (bug) (fixed)

Existing galleries (aka "Uploaded to this post") cannot be manually ordered

Reported by: devinreams's profile devinreams Owned by: nacin's profile nacin
Milestone: 3.5 Priority: normal
Severity: major Version: 3.5
Component: Gallery Keywords: has-patch commit
Focuses: Cc:

Description (last modified by SergeyBiryukov)

I'm not sure if this is worth a separate ticket and may be similar to #22488 (or may be part of a larger usability decision in #21390) but here goes: existing galleries (aka "Uploaded to this post") cannot be manually ordered which affects areas where users relied on programmatic output respecting the manual sort order of attachments to the post.

If I have a post with 5 photos uploaded and a [gallery] shortcode inline (intention: output all photos uploaded to this post), and simply want to re-order the photos, I have no discernible way to do this without inserting a new gallery shortcode to replace the existing one (with the specific id order output).

Steps:

  1. Upload multiple photos to a post (attached to post) and manually set a specific sort-order (likely using legacy media uploader/gallery manager)
  2. Insert [gallery] shortcode inline
  3. Open new "Insert Media" dialog
  4. Select "Uploaded to this post" from dropdown to show attached photos (appearing in 'gallery' shortcode)
  5. Attempt to drag/drop re-order the photos

Expected: sort order can be changed here in this "Uploaded to this post" view to re-order uploaded image order (without replacing shortcode).

Actual: all photos 'uploaded to this post' must be re-selected, ordered, and a new inline gallery needs to be used.

Also worth considering: some themes leveraged the "uploaded to this post" sort order (eg: a carousel at the top of the page) which can no longer be modified (AFAIK).

Attachments (4)

22607.diff (1.3 KB) - added by nacin 12 years ago.
An ajax endpoint for koopersmith to work with.
22607.2.diff (5.3 KB) - added by koopersmith 12 years ago.
22607.3.diff (7.4 KB) - added by koopersmith 12 years ago.
22607.uploaded.diff (1.7 KB) - added by koopersmith 12 years ago.

Download all attachments as: .zip

Change History (31)

#2 @devinreams
12 years ago

Two issues as discussed on IRC with nacin and koopersmith:

  1. [gallery] isn't getting upgraded properly (to some extent)
  2. we need to account for menu_order of images uploaded to this post

Some steps to reproduce:

  1. On 3.4.1 (r22873): upload 4 photos: http://d.pr/i/MPfO
  2. Create a manual order (different than upload order): http://d.pr/i/jyvf
  3. Insert [gallery] shortcode as-is: http://d.pr/i/jyvf and http://d.pr/i/7LmH
  4. Update WordPress trunk to 3.5-RC1 (r22873): http://d.pr/i/JVEB
  5. Confirm front-end gallery order output remains: (OK!)
  6. Confirm back-end [gallery] shortcode changed to new (NO!)
  7. Click "Gallery" editor (from Visual Editor) confirm order is correct (NO!): http://d.pr/i/I13H
  8. Change gallery order back to expected, save, confirm new gallery code (YES): http://d.pr/i/5iwE

#3 @SergeyBiryukov
12 years ago

  • Description modified (diff)

#4 @nacin
12 years ago

I opened #22608 for the default sort order of [gallery] not being menu_order.

This ticket can focus on allowing "Uploaded to this post" to be sortable, and for that sort to be saved to menu_order.

#5 @nacin
12 years ago

  • Milestone changed from Awaiting Review to 3.5

#6 @batmoo
12 years ago

  • Cc batmoo@… added

#7 @tar.gz
12 years ago

  • Cc code@… added

@devinreams and @nacin : thanks a lot for bringing this issue to the table. I would be thrilled to see this problem solved in core.

For what it's worth, I did some brainstorming about how to implement that feature and made some UI mockups here: http://ms-studio.net/notes/time-for-an-advanced-media-plugin/

Rather than adding menu_order and drag-and-drop to the Media Library view, I placed an "Attached Files" view into the left sidebar... But this was before the "Uploaded to this post" filter was added to the Media Library, so I was thinking that for a plugin it would be safer to add a new view, rather than changing the core.

A few more observations:

  • It will be a bit mysterious for the user to see that the order of the images changes when switching from "All media items" to "Uploaded to this post".
  • It might be unintuitive for the user that the Media Library allows drag-and-drop when the filter is "Uploaded to this post", but doesn't allow it when the filter is "All media items", "Images", "Audio" etc.

I don't see any easy solution for this, and it's a minor thing for sure - the most important to me is to have a solution for the manual re-ordering. :)

Another thing to consider: at what moment will the new order be saved? And how will the user know that the changes were saved? In 3.4, it was needed to press the "Save all changes" button. I think it's much better to save changes immediately after dragging an item, and to provide visual feedback (the flash of yellow that can be seen when changing/saving a custom field).

Btw, what about having this flash-of-yellow visual feedback also on the Title, Caption, and Alt fields when they are being saved? As per my testing, changes are always saved immediately, which is a great feature – but you can't be sure before you check the post preview ;)

One last thing: it would be lovely to see a "Invert Order" button here. When adding a large number of images, inverting the order by drag-and-drop is a tedious operation. In 3.4, we have the "Sort Order:Ascending | Descending" buttons. I find that feature useful when handling large galleries, but I think it could be simplified as one button, "Invert Order"... which would also be welcome in the "Create a new gallery" modal window.

#8 @bradyvercher
12 years ago

  • Cc brady@… added

@nacin
12 years ago

An ajax endpoint for koopersmith to work with.

#9 @micahwave
12 years ago

  • Cc micahwave added

#10 follow-up: @Viper007Bond
12 years ago

  • Cc viper007bond added

Would this resolve custom galleries that rely on menu_order?

#11 in reply to: ↑ 10 @nacin
12 years ago

Replying to Viper007Bond:

Would this resolve custom galleries that rely on menu_order?

Yes.

@koopersmith
12 years ago

#12 @koopersmith
12 years ago

Patch allows the "uploaded to this post" view to be sorted and updates "menu_order" on the server.

#13 @koopersmith
12 years ago

Still needs some love.

#14 @koopersmith
12 years ago

  • Keywords has-patch needs-testing added

Patch correctly updates the sort order, and will correctly update the order when new attachments are uploaded and the filter is active.

@koopersmith
12 years ago

#15 @tar.gz
12 years ago

Just tested 22607.3.diff - works perfectly for me. The fact that every change in the ordering is saved instantly is a huge benefit. Very relieved to see this feature added back, thanks so much!

#16 @ryan
12 years ago

  • Keywords commit added

Looks good here.

#17 @nacin
12 years ago

Looks great.

The only thing is, once these items have been sorted by menu_order (i.e. they're not all 0), new uploads should be added to the *end*. But, that's not how 3.4 works. It puts them all at 0, and therefore at the front, until things get moved around. In 3.5, they're put at the front but they get numbered 1-2-3 etc. We can keep that exact same behavior if we wanted if we just declined to fire refreshMenuOrder on change:uploading.

#18 @nacin
12 years ago

In 22967:

Allow the 'Uploaded to this post' view to be sorted, saving the resulting order as menu_order.

This functionality is designed to be backwards compatible with manual querying for attachments by menu_order.

props koopersmith.
see #22607.

#19 @nacin
12 years ago

  • Keywords needs-patch added; has-patch needs-testing commit removed

and will correctly update the order when new attachments are uploaded and the filter is active.

So basically, removing that restores 3.4 behavior.

#20 @koopersmith
12 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

Patch does that. Test by checking if a save-attachment-order ajax request is fired after an image is uploaded when the "uploaded to this post" filter is active.

#21 @nacin
12 years ago

  • Keywords commit added; needs-testing removed

Looks good.

#22 @nacin
12 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 22985:

Media: Don't add menu_order to newly uploaded attachments, to match 3.4 behavior. Reverts a bit of [22967]. props koopersmith. fixes #22607.

#23 @cramdesign
12 years ago

  • Cc matt@… added

#24 follow-up: @dan.rossiter
10 years ago

Has this issue regressed? Running 4.1.1 dragging items around within the Add Media dialog does nothing -- the items do not drag at all and definitely do not change menu_order.

#25 in reply to: ↑ 24 @SergeyBiryukov
10 years ago

Replying to dan.rossiter:

Has this issue regressed? Running 4.1.1 dragging items around within the Add Media dialog does nothing -- the items do not drag at all and definitely do not change menu_order.

Drag-and-drop only works in "Uploaded to this post" or "Unattached" views.

#26 follow-up: @dan.rossiter
10 years ago

@SergeyBiryukov, I understand. I was testing in the "Uploaded to this post" view.

#27 in reply to: ↑ 26 @SergeyBiryukov
10 years ago

Replying to dan.rossiter:

@SergeyBiryukov, I understand. I was testing in the "Uploaded to this post" view.

Feel free to create a new ticket if there's an issue. I could not reproduce it on a clean install though, drag-n-drop works as expected for me in the media dialog.

Note: See TracTickets for help on using tickets.