I don't want change the order of images, because it is the order of a magazine.

Original filename order,
page.jpg, page_0.jpg, page_1.jpg, page_2.jpg, page_3.jpg, page_4.jpg

If users remove and reupload the first image (page.jpg),
the order will be changed like this,
page.jpg(page_4.jpg), page_0.jpg(page.jpg), page_1.jpg(page_0.jpg), page_2.jpg(page_1.jpg), page_3.jpg(page_2.jpg), page_4.jpg(page_3.jpg), page_5.jpg(reuploaded image)

Anyone has the same problem with multiple images?

Comments

davepoon’s picture

Just forgot to mention, thumbnail imagecache has a similar problem, too.
The difference is, it will not add the new image to the end, just change the order of the existing images.

Original filename order,
page.jpg, page_0.jpg, page_1.jpg, page_2.jpg, page_3.jpg, page_4.jpg

If users remove and reupload the first image (page.jpg),
the order will be changed like this,
page.jpg(page_4.jpg), page_0.jpg(page.jpg), page_1.jpg(page_0.jpg), page_2.jpg(page_1.jpg), page_3.jpg(page_2.jpg), page_4.jpg(page_3.jpg)

markDrupal’s picture

Yeah, I see the file ordering is not 100% correct. I'll take a look at this.

markDrupal’s picture

Assigned: Unassigned » markDrupal

I think your running into this issue because you add on "_0" to your file name and this is the same behavior as Drupal's file API when it encounters a file with the same name.

In the meantime, If possible, I would suggest you alter your naming convention, although I may be able to fix this. I'll take a look.
The Regex used that is changing your filenames is.

  preg_replace('/_[0-9]+\.(.*)$/', '.$1', $new_file->filepath);

Any suggestions are welcome.

markDrupal’s picture

Status: Active » Fixed

I believe this is fixed in version 1.2, please reopen if still having issues.

davepoon’s picture

Thank you so much, I will give it a try,
and thank you for creating this excellent module!

Status: Fixed » Closed (fixed)

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