@utzer I don't think it has anything to do with the original filenames, or for that matter the order you uploaded them. They are supposed to appear in the order you attach them to your post.

But that is not happening. If you go to edit the post you'll see they are attached in your preferred order, they just aren't getting displayed that way in Friendica. And it's not the masonry layout function that's changing the order. The "Post Media Collection" array is already re-ordered before it ever gets to the masonry layout code. It's actually getting changed somewhere before the PostMedia code too. But I can't figure out where the order is being changed or why.

In the Release Candidate I added code to the post composer preview to show the masonry layout, but it has to use jQuery on the frontend, not the actual masonry code from the backend. Ironically my "simulation" of the masonry layout for the preview shows the images in the correct order while, after publishing, the actual masonry code does not.