Sorting images alphanumerically?

michoho / 2013-03-04 18:52:20   

Is there any way of doing this?

Whenever I upload images, they upload according to their upload speed and I have to drag and reorder all the images myself. This isn't a problem if there are only 10-20 images, but when I upload any more than that per exhibit, it becomes such a hassle to reorder.

Would there be any way to implement some sort of php code so I can have it sort ascending/descending according to alphanumerics?

Vaska A / 2013-03-04 19:01:48   

It's on the list of things to look at. But, ordering them alphanumerically is pretty custom...we'll be looking to try to order them the way they are uploaded.

You could always edit the exhibit format to rewrite/reorder the images array.

michoho / 2013-03-04 19:09:48   

Thanks for the quick reply.

I'm currently looking at /plugin/format.visual_index.php to see where it may be possible to do a reorder, but since I'm pretty new to this, it's hard to figure out.

Vaska A / 2013-03-04 19:21:03   

So as not to mess with the defaults, do the following...

- duplicated /ndxzsite/plugin/format.visual_index.php
- put it in your $theme folder (probably default)
- edit the file as you wish (it overrides the default now)

You can loop and rewrite the images array as you see fit. This is not something for beginners to mess with, I'll add, unless you have patience and wish to learn something about code.

michoho / 2013-03-04 19:47:54   

Is there anyway you can direct me to where the images array is located? I've looked over the php a few times but I'm having trouble spotting it due to the # of variables in the code.

Vaska A / 2013-03-04 19:57:24   

It is messy, but it has alot of features...

The images come from this function (in nearly all formats):

  1. $OBJ->page->get_imgs();

The array you want is:

  1. $this->imgs

The array has additional arrays so you will need to access it this way...

  1. foreach ($this->imgs as $arr1)
  2. {
  3.   foreach ($arr1 as $arr2)
  4.   {
  5.     // do your transformations here...like...
  6.     $new_arr[$arr2['media_file']] = $arr2;
  7.   }
  8. }

And this will get your rolling...there is more to be done but I'll let you learn some things...

michoho / 2013-03-09 18:57:04   

I've been trying the whole week to get it to sort, but I guess I'm not good in coding haha.

Vaska A / 2013-03-09 19:11:26   

That's how I learned how to code.

This thread has been closed, thank you.