How to force WordPress to add new images at the beginning of the gallery?

I just fixed this after several hours of research.
If one need to do the same thing, he must edit file wp-includes\js\media-views.js and replace add with unshift in this line (#2611, galleryAddToolbar):

edit.get('library').add( state.get('selection').models );

So the code will look like this:

edit.get('library').unshift( state.get('selection').models );

After that when you add images in the gallery they will appear at the top.

Leave a Comment