Files upload in wrong order

Hi there, hope this isn’t a silly question. When I’m uploading files (jpegs) for use in Lightbox Gallery they often are saved in the wrong order and often are mixed up. and I have to spend quite a bit of time putting them in the correct order as I’m creating a magazine and each file is a page. Does Omeka save them in a way that makes this happen? Thanks for your help. The website is

Two questions: how are you uploading these files (using Dropbox, CSV Import, just through the upload button on the interface) and what version of Omeka Classic are you using?

Hi there, I’m just using the upload button. I’m on version 3.0 but it was the same with the previous version if i remember rightly. Thanks.

OK, and one more question: are you generally doing lots of uploads at once in a single save when this happens?

Ah yes, usually around ten to twenty files at a time.

Hallo again. In addition to the files often loading in the wrong order, I’ve just discovered that many of the files I’ve uploaded and moved to their correct places have (months or years later) for some reason become all mixed up again, which is a pain as each is a page in a magazine. No idea why this is happening. Anyone got any ideas?
thanks, Greg

The general problem of fairly big-batch uploads leading to ordering issues is a known problem I’m still thinking over the best solution for.

What shouldn’t be happening regardless is that ones you have explicitly picked an order for would get out of order again. This problem really should only arise when there’s no specified order: if you reorder them and save the item, that should “lock” the ordering in place. I’m not aware of any issues that would make this not behave correctly.

The only thing I can immediately think of would be that you didn’t manually set the order for those, and that they just happened to look right initially and then “moved” later. That’s a possibility, so if that sounds like it might be what you’ve seen, it would make sense.

Hi there, thanks for getting back to me The website is an old magazine archive so every item is a magazine and every file a page of that magazine. So i have to be really careful that the files are in the same order as the original magazine. I save them and then look through the public page, turning the magazine pages to make sure that they’re in order. I could understand if i missed the odd page here and there but literally half the items have files out of order. It’s easily fixed but takes a lot of time and am concerned that they might get mixed up again. It’s not only items with over 100 files but some items that have only a few. best, Greg

What I’m suggesting is just that it’s possible that you uploaded them and checked them and they were in the right order then, so you didn’t need to move any of them, and now they’re wrong.

Some background about how this is happening: in the database we store a position for every file; this is what’s used to allow you to explicitly select an order, and we have the database return the list of files ordered by that position. The issue that arises is about how to break “ties”: what should happen when more than one file says it should be in the same position? The way things work now, the database gets to just return those in any order it wants between any “tied” files, whatever’s most convenient or efficient for it to do.

The final piece of the puzzle is that files, when first uploaded to Omeka Classic, don’t set any particular order, so they’re all “tied.” If you upload 5, 10, 15, whatever number of files together, those all have the same position or order: it’s unspecified for all of them. So there’s essentially no guarantee on the order between those, and it can even change over time.

In the current code, what prevents this is editing the item and changing the order of any file once the files are already uploaded. Saving a item after moving one file sets the order of all the files currently stored on it, so there are no ties, no ambiguity, and they won’t “move.” This is why I think the possible situation you’re in is that this is happening to items where you didn’t have to manually fix them the first time around: those files all still have unspecified order.

There’s a solution to this we can apply in the code, to make it so that the order of these “tied” files is consistent. What we’d do is change this line of the file application/models/Table/File.php, line 195



to instead read


What this does is say that whenever there’s a tie in the order or it’s unspecified, to use the file’s ID as the order. This should have the effect of fixing the problem going forward for newly added files, and should also fix any prior “untouched” items where you haven’t explicitly set an order. Items where you have set an order would be unaffected: the order you chose should remain as-is.

If you’re comfortable, you might try making that change. If it works well for you it would be evidence that this is a change we should make in a future update to Omeka Classic. Particularly if you’re in a situation where you have lots of problematic items with mixed-up files now, this solution could both save you time and be a valuable example of a real-world case of the problem we’d be solving in action.

Hi there, thanks for the explanation. I was struggling a bit to get my head around it. That explains it. I just assumed that files were in order of upload or number etc. I’ve changed that code. I’ll let you know how I get on. Thanks again for your help. best, Greg

Hi again, everything seems to be working perfectly now! I did a test and 100 files uploaded perfectly, which has never happened before and all the ones that were out of order are back in their proper place, literally a thousand or more files. Thanks again! This saves such a lot of time.

OK, good to hear. Thanks for reporting your experience.

Probably what we’ll do is make this change in a future version of Omeka Classic.

Omeka Classic 3.1.2 contains this change.

Ah that’s brilliant. Thanks!