Hi, how i can automaticaly sort uploaded images by name? Now, it sort randomly, i think.

Comments

matjes’s picture

Is there a way to sort the extracted images by name?

pacome’s picture

Hello
thanks for this module, it's pretty usefull !

But I also have this issue..
When I upload a zip containing a serie of pics like "img01 - img02 - img03 ....", they are all sorted randomly..

I think the point of a good image gallery is to be sorted in a certain way.
Then if a bulk upload doesn't sort by name, it only do half the job...

Is there a way to solve that ?

Best
-P-

tike012’s picture

Category: task » bug

Changed category to bug report because I don't think the random sorting is supposed to happen. I've looked at the code but nothing I've tried seems to fix the problem. Will keep trying.

dman’s picture

Status: Active » Needs review
StatusFileSize
new5.65 KB

Yeah, found it.
Turns out that the cck bit that renders the table does not respect either the element order, the delta or the normal #weight settings from FAPI.
Instead it uses its own _weight hidden value and sorts on that.
If you create file fields using the UI, that normally works, but creating the fields though code - as happens here, skips that step.
If _weight is not set, the sorter produces semi-random results, even if your images were nicely names IMG_001, IMG_002, etc

Here's a patch.

Patch also includes some added error handling and logging that I found necessary when debugging. It turned out the code needed a bit of waterproofing against unexpected conditions.

mikeytown2’s picture

Status: Needs review » Fixed

committed the patch. dman let me know if you want CVS; I took over this project because I found it useful.

Status: Fixed » Closed (fixed)

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