Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files replaced with same name + dimensions never regenerate #2

Open
josephlewisnz opened this issue May 4, 2023 · 3 comments
Open

Comments

@josephlewisnz
Copy link

I've had an investigation and I believe this is due to the fact the variant remains the same and no hash check is done.

<source media="(max-width: 768px)" type="image/webp" srcset="$ScaleWidth(768).Format('webp').URL">

To Replicate

  1. Upload a file with set dimensions
  2. Using the "Replace the file" functionality upload a different image (same dimensions and name)
  3. See front end still shows the "old" image

I will be investigating to see if there is a fix here, however, I also see a comment as to why the hash is not used, so maybe this is not possible and another approach is needed.

" * Stop caring about hash when checking for file collisions; This breaks many things.
* Specifically, the "original" image and the formatted image will have different hashes,
* but we cannot determine the formatted hash without generating it, or storing it somewhere. "

@tractorcow
Copy link
Owner

@josephlewisnz silverstripe image backend used to use the hash in all urls (even public image urls) but I believe in recent times the default has been changed to short urls sans-hash in the path for public images.

If you can re-configure your asset backend to route public images with hash you'll probably resolve the above issue.

It's all been rewritten since I have poked my head into the code (years ago haha), so unfortunately you may need to dig up and investigate the answer yourself.

@tractorcow
Copy link
Owner

tractorcow commented May 5, 2023

yeah this is the new parser

https://github.com/silverstripe/silverstripe-assets/blob/2/src/FilenameParsing/NaturalFileIDHelper.php#L8

  • Parsed Natural path URLs. Natural path is the same hashless path that appears in the CMS.

Reconfigure the public store to use this one instead and it'll probably fix it

https://github.com/silverstripe/silverstripe-assets/blob/2/src/FilenameParsing/HashFileIDHelper.php

  • Parsed Hash path URLs. Hash paths group a file and its variant under a directory based on a hash generated from the
  • content of the original file.

and config at

https://github.com/silverstripe/silverstripe-assets/blob/2/_config/asset.yml#L29-L33

best of luck

@josephlewisnz
Copy link
Author

Thanks @tractorcow for the direction. I will update here if I make any progress!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants