Patch (to be ported)
Project:
Imagefield Import
Version:
6.x-1.x-dev
Component:
Miscellaneous
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
9 Nov 2010 at 07:48 UTC
Updated:
25 Apr 2012 at 15:21 UTC
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
Comment #1
Drupalized commentedsame here. any comment?
Comment #2
Drupalized commentedOk, 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.