Hello, i have a problem with upload many images to one node. The uploaded images are in randopm order. I would like to upload order by image (file) name. Is it possible?

Comments

Drupalized’s picture

same here. any comment?

Drupalized’s picture

Title: Wrong order with upload many images to one node. » Wrong (file system) order with upload many images to one node.
Version: 6.x-1.9 » 6.x-1.x-dev
Assigned: Unassigned » Drupalized
Status: Active » Patch (to be ported)

Ok, i have a hack for this. In the "imagefield_import.module" (latest dev version of module in this time);

1-) add this to line ~334 just after this line -> $files = file_scan_directory($directory, '.*');

uksort($files,'cmp');

2-) add this function to same file's end

function cmp( $a, $b ) {
$pathinfo_a = pathinfo($a);
$pathinfo_b = pathinfo($b);
$pathinfo_a = explode('_',$pathinfo_a["filename"]);
$pathinfo_b = explode('_',$pathinfo_b["filename"]);
if( $pathinfo_a[1] == $pathinfo_b[1] ){ return 0 ; }
return ($pathinfo_a[1] < $pathinfo_b[1]) ? -1 : 1;
}

That's it!

This will sort importing images by filename.

Important : this will work on "import all images" option. You can add same function call to "select images" function in same module file to extend functionality.