Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#30640 closed defect (bug) (invalid)

Order/sort of attachments logic

Reported by: Stagger Lee Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0.1
Component: Media Keywords: close
Focuses: Cc:


Sorry for making this as "defect", other 2 options doesnt seems right here too.

I explained everything here in detail.


Now, i just ask for some explanation why it is such logic and why such behaviour ?

Some C/P from this topic:

  • My images are named as _DSCXXX.
  • I upload say 200 images from one party at once, no errors, all went fine.

(number of images is not relevant here, I just use pagination for multiple galleries per post)

  • I uppload them in the post, they are ordered OK after logic. Last uploaded is at the top, it means my last at the bottom of Windows Explorer window. So long logic is respected.
  • I preview images in "All media items", they are shown nice, as it was upload order.

And now comes hell.

  • "Uploaded to this post" cannot keep same logic as "All media items".
  • Even if I naive tought i could use only "All media items" for building galleries, in my sight (view) i check images and all seems OK, but as soon i make gallery they are again randomized.

It is not classic random functions, rows seems to keep upload order, but they are shifted.
So you have say 3 rows from end at the beginning, 3 rows from beginning at the end, rows in the middle are shifted to. Abosultely no logic in this sorting.

Change History (6)

#1 @Stagger Lee
6 years ago

Most important thing here is this, and for heaven i cannot explain it:

  • Ajax load of images in "Uploaded to this post".
  • First opening of this view shows images in perfect order.
  • But as soon I scroll down to see all say 200 images, and come back to te top of this view, some images that should be at the bottom are now at the top of this view. (not "reversed" logic, as i said it randomize multiple rows)
  • And so will be sorting in gallery, so will be sorting at frontend.
Last edited 6 years ago by Stagger Lee (previous) (diff)

#2 @Stagger Lee
6 years ago

Found one more thing. If i use "All media items" and check gallery images with Ctrl + click on each image then it works.
If i use Shift + click on last image for gallery, then it is randomized in some way.

It can work in "All media items" because this view doesnt shuffle images when i scroll down. But not in "Uploaded to this post". As soon i past (scroll down) some row levels it shuffle by itself.

Man this is so confusing.

#3 @Stagger Lee
6 years ago

I just tested to rise number of attachments pulled by Ajax, even risking server limits. Easy to revert it back. First i C/P code from media-models.js to media-models.min.js for easier troubleshooting. And changed line 1144 to:

defaultArgs: {
			posts_per_page: 300

Just for quick test, any number above my number of images uploaded to this post.

Guess what ? Of course order of images are exactly as in "All media items". Can someone says a word about it ?
Is it complicated to solve in core.

As it is now "Uploaded to this post" can only be used for galleries with 5-10-20-40 images. It is shame. because Media Manager has undergone nice code change, became very powerfull, and native WP gallery now can replace very powerfull gallery plugins.
With custom post types and custom fields there would be absolutely no need for any other media plugin.

Last edited 6 years ago by Stagger Lee (previous) (diff)

#4 @Stagger Lee
6 years ago

This fix helped me with sorting problem. Not 100% but it can be used now without big problems.
I will test it more next days.



(How do you link trac numbers ?)

Last edited 6 years ago by SergeyBiryukov (previous) (diff)

#5 @Stagger Lee
5 years ago

  • Keywords close added
  • Resolution set to invalid
  • Status changed from new to closed

This one is fixed long time ago.
Dont know what is the right way to close it.

#6 @samuelsidler
5 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.