I noticed that when I use autosort, the pictures are sorted from newest to oldest.
I'm not sure if it's by design, but I kind of like that if i click the picture it goes from oldest to newest (by date). So if someone needs it quick, I'll just upload the patch here.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jānis Bebrītis’s picture

this one is gonna be a bit smarter, it will be ascended on first click and descended on second one.

shemgp’s picture

FileSize
656 bytes

How about this one? I'm not sure if this is the proper way of doing it.

Jānis Bebrītis’s picture

good, I just modified it a bit, so that session variables are used instead (because variable_set/get is stored in database for shared use between all users).

And it looks like this now:

        // sort
        $sort = isset($_SESSION['prog_gallery_autosort']) ? $_SESSION['prog_gallery_autosort'] : 'asc';
        
        if ( $sort == 'asc' ) array_multisort($exif_arr_date, SORT_ASC, SORT_NUMERIC, $exif_arr_nid);
        else  array_multisort($exif_arr_date, SORT_DESC, SORT_NUMERIC, $exif_arr_nid);
        
        $_SESSION['prog_gallery_autosort'] = ($sort == 'asc') ? 'desc' : 'asc';

based on this, "Autosort" button finally got it`s icon ;)

manoloka’s picture

this one is gonna be a bit smarter, it will be ascended on first click and descended on second one.

Is this supposed to be implemented already?

Jānis Bebrītis’s picture

Assigned: Unassigned » Jānis Bebrītis
Status: Needs review » Fixed

it is, and was commited into cvs 9 seconds ago :)

shemgp’s picture

I just noticed that if i use array_multisort it doesn't sort or pictures without exif data. So, when i click the autosort button again, it doesn't reverse the order of the pictures that doesn't have exif data. Although, it still places the whole group of unsorted pictures in front or at the end of the exif sorted pictures.

example, using array_multisort only (where u = unsorted, e = exif sorted):
asc:
u3 u2 u1 e1 e2 e3
desc:
e3 e2 e1 u3 u2 u1

where when using array_reverse after array_multisort
asc:
u3 u2 u1 e1 e2 e3
desc:
e3 e2 e1 u1 u2 u3

I kind of liked it to reverse the order of pictures if i click it, but i'm not really sure what the intent of autosort is. Should it be by date only and if there's no, date ignore it?

Jānis Bebrītis’s picture

Status: Fixed » Postponed (maintainer needs more info)

what parameter is using array_reverse to sort uX ? Is there any other really usable field to sort images? It could be title.. but then again - why, and would it be practical? could it be body? but then again - why, and would it be practical again? :)

What do you think? Photo galleries are for photos, usually they have the most pictures and they have exif data. I guess this is as far as I can really help with this feature.

I`d like to review benefits using array_reverse tho`.

shemgp’s picture

Yup, i realized that too =). I guess if the design of the autosort is that when it's clicked the second time the order of how the pictures are currently sorted will be reverse, then maybe array_reverse should be used. Because it reverses it even if the pictures don't have exif.

Jānis Bebrītis’s picture

thats really good point.

update: now it looks like this

        // sort
        array_multisort($exif_arr_date, SORT_ASC, SORT_NUMERIC, $exif_arr_nid);
        
        $sort = isset($_SESSION['prog_gallery_autosort']) ? $_SESSION['prog_gallery_autosort'] : 'asc';
        if ( $sort == 'asc' ) $exif_arr_nid = array_reverse( $exif_arr_nid );
        $_SESSION['prog_gallery_autosort'] = ($sort == 'asc') ? 'desc' : 'asc';

and it`s uploaded into cvs ;) Friend of mine said that they could be sorted by title when its like IMG_1022.JPG.. but then again - those pictures have exif date in header anyway.

Jānis Bebrītis’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.