Jump to content

Sort Images in PW (not on live page)


Russ Parker
 Share

Recommended Posts

Currently when you upload images in PW, they are display in the order that they finished uploading - not necessarily in the order that they need to be in.

I have a client that will be uploading approx. 100 images per page and needs them in filename order so that he can annotate each image using the description box.

I can get PW to spit out the live page in the correct order:

$images = $page->images->sort('name');

But this only works on the live page, which means that inside PW it is still a bit of a mess and my client still needs to reshuffle the images by hand in order to get the annotation right.

Is there a way to get PW to sort the uploaded images in the page editor?

Link to comment
Share on other sites

You could use a autoload module like this https://processwire-recipes.com/recipes/extending-page-save-process/ and use it to change the order of the images on page save. This way you client still has to hit save, but at least it's not manual work. 

$page->images = $page->images->sort('name');

The other option would be hooking into ProcessPageEdit and adding a javascript file which does the sorting right away.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...