Skip to content
Snippets Groups Projects

Flush image styles when replace method is used

1 file
+ 8
0
Compare changes
  • Side-by-side
  • Inline
@@ -248,6 +248,14 @@ class FileImport extends FileCopy {
@@ -248,6 +248,14 @@ class FileImport extends FileCopy {
// If this was a replace, there should be an existing file entity for it
// If this was a replace, there should be an existing file entity for it
// And if so, we return it. Otherwise, one will be created further down.
// And if so, we return it. Otherwise, one will be created further down.
if ($file = $this->getExistingFileEntity($final_destination)) {
if ($file = $this->getExistingFileEntity($final_destination)) {
 
// If this was a replace, need to flush all its image styles,
 
// otherwise they don't regenerate with the updated image content.
 
if (
 
$this->configuration['file_exists'] === FileSystemInterface::EXISTS_REPLACE ||
 
(enum_exists(FileExists::class) && $this->configuration['file_exists'] === FileExists::Replace)
 
) {
 
image_path_flush($file->getFileUri());
 
}
return $id_only ? $file->id() : ['target_id' => $file->id()];
return $id_only ? $file->id() : ['target_id' => $file->id()];
}
}
}
}
Loading