Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#17485 closed defect (bug) (fixed)

Sort Order by Date in WP Gallery resorts to order by ID

Reported by: nrajesh's profile nrajesh Owned by: westi's profile westi
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.1.2
Component: Gallery Keywords: 3.3-early westi-likes 2nd-opinion
Focuses: Cc:

Description

Create a blog. Add some pics to it. Click "Add Media" link in the edit post screen itself and select the gallery and chose default sort order as "Date/ Time". Code will be generated as something like this
[gallery link="file" columns="5" orderby="ID"]. Pay attention to orderby value!

This has been present for almost an year (see http://wordpress.org/support/topic/wordpress-gallery-feedback?replies=6) - I guess this was pre 2.9.2 version.

Partly a miss from my side also, because I raised it in this support forum but never thought of raising it in the bug tracking system (until today)!

In the WP codex also I am not able to spot the code that does the order by date. Simply using [gallery orderby="Date" ...] does not work either!

Attachments (1)

17485.patch (611 bytes) - added by SergeyBiryukov 14 years ago.

Download all attachments as: .zip

Change History (34)

#1 @azaozz
14 years ago

Actually order by date = order by ID as the ID field is self-incrementing and there's no scheduled publishing for attachments. So if you upload 5 images at the same time they will get consecutive IDs according to the order they were uploaded. If you upload them separately (i.e. one upload every hour, etc.) the IDs would still match the order they were uploaded.

You can test this by running couple of simple SELECT from phpMyAdmin or similar.

#2 @azaozz
14 years ago

  • Keywords close added; needs-patch removed

#3 follow-up: @nrajesh
14 years ago

  • Cc nrajesh added
  • Owner set to azaozz
  • Status changed from new to reviewing

In such a case what is the need for order by Date/ Time? I guess this feature was thought to be order by Date/ Time of the image itself i.e. time taken - this will make a lot more sense.

For example the images I have uploaded in one shot gets uploaded according to the name I've given them (I could have renamed images before uploading them); but on the blog I want them to appear in some sequence of events. I guess me and a couple more folks @ http://wordpress.org/support/topic/wordpress-gallery-feedback?replies=6 have misunderstood the Order by Date/ Time to be capable of doing this!

#4 in reply to: ↑ 3 @azaozz
14 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from reviewing to closed

Replying to nrajesh:

Yes, ordering by date/time is on the upload/attachment creation time. Strictly speaking if you take several photos in a sequence, then upload them in the same sequence (which usually is the case) they will appear in that sequence.

However if you want to be in control of the gallery ordering, go to the gallery settings, set it to "menu order" then rearrange the items in the listing abode (they are draggable).

#5 @nrajesh
14 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

I can understand that you say ordering by date/ time is on upload attachment creation time. In fact that is what we expect of this feature.

But what I am saying is this functionality does not work at all. It fails to recognize file ordering by date of creation and in fact inserts a wrong short code!

Simply loading a couple of files called 1.jpg,2.jpg,3.jpg will work anyways because of this bug (order by date resets to order by id)! That's why I said rename those files and see if order by date/ time works.

I do not want to control gallery ordering beyond the above mentioned point. Hope I made it clear this time.

#6 @nrajesh
14 years ago

  • Status changed from reopened to reviewing

#7 @dd32
14 years ago

nrajesh: ID's are created sequentially, Id 5 comes before ID6, comes before ID 100. Therefor, Date and ID ordering is exactly the same.. Ordering by ID is vastly faster than ordering by date in term of performance (even though it's minimal).

From what you've said so far, It seems that you're saying this isn't the case? Is that right?

The Order by date stamp on the gallery settings is to give the simplest language explanation, rather than "But what order is ID's?".. The shortcode is designed to reflect the settings selected, not to necessarily be read.

#8 follow-up: @nrajesh
14 years ago

  • Owner changed from azaozz to dd32

You are right about Ids are getting created sequentially - but what determines their sequence? Surely not the creation time of the pics - because when I upload 10 pics at a time they are appearing sorted by their names rather than their creation date. My complaint is that chosing the "Order by date" option did not help. Please clarify!

#9 in reply to: ↑ 8 @azaozz
14 years ago

  • Resolution set to worksforme
  • Severity changed from critical to normal
  • Status changed from reviewing to closed

Replying to nrajesh:

You are right about Ids are getting created sequentially - but what determines their sequence? Surely not the creation time of the pics...

No, it's not the creation time of the images, it's the upload time. The IDs are an auto-increment field in the database and each is created as the next image is uploaded.

#10 @westi
14 years ago

  • Keywords 3.3-early westi-likes added; close removed
  • Milestone set to Future Release
  • Resolution worksforme deleted
  • Status changed from closed to reopened

I'm re-opening this ticket because I don't think the user experience on this is right for a number of reasons:

  • The UI should describe exactly what it is doing not say one thing and do something else - even if the two things are normally the same.
  • It is possible to add UI / logic in a plugin to modify the dates on attachments / set them to shooting date based on EXIF data which will then likely completely break this sorting method.
  • We probably should be using the EXIF data for photos to set the date to the date when they were taken (or make this something that is easier to enable in core) to make photoblogging easier.

Therefore in my opinion we should at least relabel the UI here and probably completely review the way in which we treat uploaded photos with EXIF data.

#11 follow-up: @westi
14 years ago

Note you can do: [gallery orderby="post_date"] at the moment in trunk so we could just hook the UI up to do that instead of [gallery orderby="ID"]

EXPLAIN on both queries is the same:

1 	SIMPLE 	wp_posts 	ref 	type_status_date,post_parent 	post_parent 	8 	const 	1 	Using where; Using filesort

#12 in reply to: ↑ 11 ; follow-up: @azaozz
14 years ago

Replying to westi:

Note you can do: [gallery orderby="post_date"] at the moment in trunk so we could just hook the UI up to do that instead of [gallery orderby="ID"]

EXPLAIN on both queries is the same:

And the result of both queries is exactly the same :)

The problem here seems to be that upload time is often the same as creation time for photos, but not always. So the users may get confused.

Not sure it's good idea to set attachment creation time according to EXIF. IMO EXIF data belongs in postmeta.

In any case we should expand the use of that data when available including rotating the image, (more?) camera details, creation time, etc. but that seems out of scope for this ticket.

What we can do here is change the "Sort by: Date" to "Sort by: uploaded time" or similar which should remove any confusion.

#13 in reply to: ↑ 12 @westi
14 years ago

Replying to azaozz:

Replying to westi:

Note you can do: [gallery orderby="post_date"] at the moment in trunk so we could just hook the UI up to do that instead of [gallery orderby="ID"]

EXPLAIN on both queries is the same:

And the result of both queries is exactly the same :)

Only if I haven't edited the dates to correct them to match when I took the photos.

The problem here seems to be that upload time is often the same as creation time for photos, but not always. So the users may get confused.

I think in general upload time and creation time for photos are not the same.

I think more people upload photos they took hours/days/weeks in the past than upload to WordPress straight from there camera.

Not sure it's good idea to set attachment creation time according to EXIF. IMO EXIF data belongs in postmeta.

In any case we should expand the use of that data when available including rotating the image, (more?) camera details, creation time, etc. but that seems out of scope for this ticket.

What we can do here is change the "Sort by: Date" to "Sort by: uploaded time" or similar which should remove any confusion.

We can do that ... but ... sort by date the photo was taken is more useful to a Photoblogger than sort by upload time.

#14 @scribu
14 years ago

westi, consider the case where some photos have exif data, while others don't.

I agree with azaozz that labeling "Sort by: uploaded time" is the best approach for this ticket.

#15 @scribu
14 years ago

That said, I do like the idea of being able to order photos based on the date they were taken, but only where galleries are concerned. If we were to automatically set the post_date based on EXIF data, it would affect the listing in the admin as well.

So, I think this should be discussed more thoroughly in a separate ticket.

#16 follow-up: @azaozz
14 years ago

Replying to westi:

I think in general upload time and creation time for photos are not the same.

I think more people upload photos they took hours/days/weeks in the past than upload to WordPress straight from there camera.

Right, didn't explain this well. When taking photos the camera saves the files with sequential names. Later when transferring the photos to a PC or uploading them directly from the memory card they are still sorted in that sequence and they are usually uploaded in the same sequence. So the upload time is not the same as creation time, but the sequence is usually the same.

We can do that ... but ... sort by date the photo was taken is more useful to a Photoblogger than sort by upload time.

Agree, but currently we support sorting by upload time, we would need to correctly describe that.

I would like to see sorting by EXIF data in core too. Furthermore we have a GSoC project that is replacing the uploader, think it will be possible to pass the file creation times while uploading too. That could be used to sort images that do not have EXIF data. My only remark is that this seems out of scope for this ticket and we will be better off opening a new one.

@scribu was answering at the same time as you, sorry to repeat what you're saying :)

#17 in reply to: ↑ 16 @westi
14 years ago

Replying to scribu:

westi, consider the case where some photos have exif data, while others don't.

I agree with azaozz that labeling "Sort by: uploaded time" is the best approach for this ticket.

The best approach to this problem is to change our sorting when you click this option to post_date.

  • It has no affect on people who are not correcting the date/time
  • It makes the feature work as intended for those who do.

Replying to scribu:

That said, I do like the idea of being able to order photos based on the date they were taken, but only where galleries are concerned. If we were to automatically set the post_date based on EXIF data, it would affect the listing in the admin as well.

So, I think this should be discussed more thoroughly in a separate ticket.

The EXIF data is a tangential related issue which I agree should be on a separate ticket.

Replying to azaozz:

Replying to westi:

I think in general upload time and creation time for photos are not the same.

I think more people upload photos they took hours/days/weeks in the past than upload to WordPress straight from there camera.

Right, didn't explain this well. When taking photos the camera saves the files with sequential names. Later when transferring the photos to a PC or uploading them directly from the memory card they are still sorted in that sequence and they are usually uploaded in the same sequence. So the upload time is not the same as creation time, but the sequence is usually the same.

We can do that ... but ... sort by date the photo was taken is more useful to a Photoblogger than sort by upload time.

Agree, but currently we support sorting by upload time, we would need to correctly describe that.

As I said above I think the best solution is s/ID/post_date/ because that gives the best solution for both use cases without cluttering the UI.

Changing it to say sort by upload date just makes it lamer IMHO.

#18 @scribu
14 years ago

Ok, let's just change it to post_date then.

Actually, won't that happen if we just remove the order attribute?

#19 @danielbachhuber
14 years ago

  • Cc d@… added

#20 @westi
14 years ago

  • Owner changed from dd32 to westi
  • Status changed from reopened to accepted

#21 follow-up: @SergeyBiryukov
14 years ago

  • Keywords has-patch added

#22 in reply to: ↑ 21 ; follow-up: @azaozz
14 years ago

Replying to SergeyBiryukov:

No, this patch doesn't solve the reporter's problem. As far as I understand he expects to have the images sorted by the date/time he took them, not by the upload date/time. To do that we would need to look into exif data (and hope it exists and is accurate).

#23 @SergeyBiryukov
14 years ago

  • Keywords needs-patch added; has-patch removed

#24 follow-up: @jane
14 years ago

  • Type changed from defect (bug) to enhancement

Date/time everywhere else in the admin refers to when something was published, created, or uploaded. I'm not really comfortable with making language mean one thing for images with exif data and another thing for everyone else. Given that we're already going to be up to our ears in UI with the new uploader, I'd rather see this start as a plugin, and then integrate it when there is a really good solution.

Changing te enhancement because it does work as intended currently.

#25 @nrajesh
14 years ago

  • Owner changed from westi to SergeyBiryukov
  • Status changed from accepted to assigned

Understood about the tight schedule. In which case why not just rename it as sort by upload date instead. Not sure if that changes anything but from this ticket's perspective at least it avoids confusing language. Up to the devs now to prioritize this proposed name change.

#26 @jane
14 years ago

  • Owner changed from SergeyBiryukov to westi

@nrajesh: Please leave it to the core team to change the "assigned to" field. This is used not to indicate who is writing a patch, but who will be overseeing the component as many times a patch goes through multiple authors and iterations before being committed.

#27 in reply to: ↑ 22 ; follow-up: @SergeyBiryukov
14 years ago

  • Keywords close added

Replying to azaozz:

As far as I understand he expects to have the images sorted by the date/time he took them, not by the upload date/time. To do that we would need to look into exif data (and hope it exists and is accurate).

Then it looks like a duplicate of #16251.

#28 @nrajesh
14 years ago

Just saw that thread. Seems like the guy who started it also have a working solution to the issue that has been raised here. My suggestion: why not add this as the 3rd option in addition to existing sort by id, sort by (upload) date? I ask assuming the code given in the other thread works.

#29 in reply to: ↑ 27 @westi
14 years ago

  • Keywords close removed

Replying to SergeyBiryukov:

Replying to azaozz:

As far as I understand he expects to have the images sorted by the date/time he took them, not by the upload date/time. To do that we would need to look into exif data (and hope it exists and is accurate).

Then it looks like a duplicate of #16251.

that is a similar and related issue but not a duplicate

#30 in reply to: ↑ 24 @westi
14 years ago

  • Type changed from enhancement to defect (bug)

Replying to jane:

Date/time everywhere else in the admin refers to when something was published, created, or uploaded. I'm not really comfortable with making language mean one thing for images with exif data and another thing for everyone else. Given that we're already going to be up to our ears in UI with the new uploader, I'd rather see this start as a plugin, and then integrate it when there is a really good solution.

Changing te enhancement because it does work as intended currently.

It doesn't though.

There is a very specific bug here with how the UI represents the underlying functionality and a lot of discussion around enhancements that are covered by a different ticket.

The focus of fixing the bugs in this ticket relate to the fact that we have a UI option for sort by "Date" and we do a sort by "ID" which is confusing and unnecessary.

Last edited 14 years ago by westi (previous) (diff)

#31 @SergeyBiryukov
14 years ago

  • Keywords 2nd-opinion added; needs-patch removed

#32 @westi
14 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In [18596]:

When inserting a Gallery to be ordered by Date/Time use the post_date field for ordering rather than ID so that if the user/plugin has updated this to reflect the date/time when an image was captured we order correctly. Fixes #17485 props SergeyBiryukov.

#33 @SergeyBiryukov
14 years ago

  • Milestone changed from Future Release to 3.3
Note: See TracTickets for help on using tickets.