Skip to content

Commit c34f851

Browse files
authored
Merge pull request #6 from perryholden/main
Add placeholder path guard to avoid removing placeholder images
2 parents 91109e0 + 0fe8518 commit c34f851

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Console/Command/RemoveUnusedMediaCommand.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public function execute(InputInterface $input, OutputInterface $output): void
6767
$imagesToKeep = $connection->fetchCol('SELECT value FROM ' . $mediaGalleryTable);
6868

6969
foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
70-
// Cached path guard
71-
if ($this->isInCachePath($file)) {
70+
// Cached and placeholder path guard
71+
if ($this->isInCachePath($file) || $this->isInPlaceholderPath($file)) {
7272
continue;
7373
}
7474

@@ -122,4 +122,9 @@ private function isInCachePath(?string $file): bool
122122
{
123123
return strpos($file, '/cache') !== false;
124124
}
125+
126+
private function isInPlaceholderPath(?string $file): bool
127+
{
128+
return strpos($file, '/placeholder') !== false;
129+
}
125130
}

0 commit comments

Comments
 (0)