When True Crop generates a new filename, it currently does not take into account the possibility that a previous crop has been deleted.

So for example, if picture.jpg, picture_2.jpg, and picture_4.jpg exist (with picture_3.jpg having been deleted) it will currently create a new crop as picture_3.jpg. It would be better to create picture_5.jpg in that case; this is more logical for the list of files in the administrative interface, and also has the advantage that it avoids reusing the URL of a deleted file (which could be cached somewhere, etc) when possible to avoid doing so.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein created an issue. See original summary.

David_Rothstein’s picture

Status: Active » Needs review
FileSize
2.63 KB

Here is a patch.

David_Rothstein’s picture

Title: Avoid reusing out-of-sequences names of deleted files for new crops » Avoid reusing out-of-sequence names of deleted files for new crops
Status: Needs review » Fixed

Committed the fix.

  • David_Rothstein committed e8b864a on 7.x-1.x
    Issue #2766419 by David_Rothstein: Avoid reusing out-of-sequence names...
David_Rothstein’s picture

I committed a followup fix to change the query to use db_like() so it will work correctly even if there are wildcard characters in the filename. Attaching the final combined patch that was added to the module via this issue.

  • David_Rothstein committed ce9664f on 7.x-1.x
    Issue #2766419 by David_Rothstein: Followup to use db_like() in the new...
David_Rothstein’s picture

And another followup commit to make this all work when the original image (e.g. "picture.jpg") is the one that was deleted.

  • David_Rothstein committed ca6c482 on 7.x-1.x
    Issue #2766419 by David_Rothstein: Followup to make the new True Crop...

Status: Fixed » Closed (fixed)

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