I'm thinking this is a limitation of Drupal and there isn't anything this module can do but throwing this out there if anyone has any ideas.

I have a field collection on my node which has an image field. I have my tokens set up for my file name:

[field_collection_item:host:node:field-line-ref]-[field_collection_item:host:node:field-line-ref:field-term-line-type]-[field_collection_item:host:node:field-term-season]-[field_collection_item:host:node:field-term-year]-[field_collection_item:host:node:title].[file:ffp-extension-original]

This works great. When I have multiple field collections, Drupal is smart enough to append a counter number to the file name. For example:

my-line-test-spring-2016-style-1111-node-title.jpg
my-line-test-spring-2016-style-1111-node-title_0.jpg
my-line-test-spring-2016-style-1111-node-title_1.jpg

The problem is if I edit these images it names them exactly the same thing. For example, If I remove the second image: my-line-test-spring-2016-style-1111-node-title_0.jpg and reupload a new image it names it: my-line-test-spring-2016-style-1111-node-title_0.jpg. This is a problem because the old image is cached on the user's browser.

I am thinking that we would need to write something like this:

  1. Create a table that stores the uri, fid, and append number.
  2. In filefield_paths_filefield_paths_process_file() before file_move search the database to see if there is a uri that exists in this new table and write some logic to handle appending the correct digit to the uri
  3. In hook_cron delete any fids that are not used

Comments

albertski created an issue.