Problem/Motivation
Right now, if an image style configuration changes, it removes all the generated images in this function:
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
parent::postSave($storage, $update);
if ($update) {
if (!empty($this->original) && $this->id() !== $this->original->id()) {
// The old image style name needs flushing after a rename.
$this->original->flush();
// Update field settings if necessary.
if (!$this->isSyncing()) {
static::replaceImageStyle($this);
}
}
else {
// Flush image style when updating without changing the name.
$this->flush();
}
}
}
Now, on a huge high-traffic website will gigabytes of images, this means the server must regenerate everything. For example:
- if you consider doing that on a 100 GB dataset, then the server load will be going ultimately high later because of regenerating this much content again.
- Also, if you're using AWS S3 or Google Cloud Storage for files, this means a lot of extra traffic and file writing process. That adds extra cost.
Situations where we found this idea useful:
- We already generated WEBP derivatives with ImageAPI Optimaze WEBP. But when core was able to generate WEBP images we switched to that. We wanted to reuse those existing generated WEBP images after the image style config change, and not regenerate thousands of same ones.
- Newsletters were sent out with embedded JPG derivatives and we didn't want to remove those JPG images when we changed the image style to convert to WEBP always.
Also, I think only a little percent of visitors or even content editors care about the older images. It would be awesome if we could temporarily switch off automatic removing derivatives while we're deploying the new configuration, for example in the settings.php. What do you think?
Steps to reproduce
Proposed resolution
Remaining tasks
Update issue summary
Add test coverage
Code review
User interface changes
API changes
Data model changes
Release notes snippet