diff --git a/app/Console/Commands/CleanupImages.php b/app/Console/Commands/CleanupImages.php
index f2e2d9fbd..93ca367a2 100644
--- a/app/Console/Commands/CleanupImages.php
+++ b/app/Console/Commands/CleanupImages.php
@@ -14,8 +14,8 @@ class CleanupImages extends Command
* @var string
*/
protected $signature = 'bookstack:cleanup-images
- {--a|all : Include images that are used in page revisions}
- {--f|force : Actually run the deletions}
+ {--a|all : Also delete images that are only used in old revisions}
+ {--f|force : Actually run the deletions, Defaults to a dry-run}
';
/**
diff --git a/app/Uploads/ImageService.php b/app/Uploads/ImageService.php
index 5c16827cb..92c3994a7 100644
--- a/app/Uploads/ImageService.php
+++ b/app/Uploads/ImageService.php
@@ -304,22 +304,19 @@ class ImageService
* Could be much improved to be more specific but kept it generic for now to be safe.
*
* Returns the path of the images that would be/have been deleted.
- * @param bool $checkRevisions
- * @param bool $dryRun
- * @param array $types
- * @return array
*/
- public function deleteUnusedImages($checkRevisions = true, $dryRun = true, $types = ['gallery', 'drawio'])
+ public function deleteUnusedImages(bool $checkRevisions = true, bool $dryRun = true)
{
- $types = array_intersect($types, ['gallery', 'drawio']);
+ $types = ['gallery', 'drawio'];
$deletedPaths = [];
$this->image->newQuery()->whereIn('type', $types)
- ->chunk(1000, function ($images) use ($types, $checkRevisions, &$deletedPaths, $dryRun) {
+ ->chunk(1000, function ($images) use ($checkRevisions, &$deletedPaths, $dryRun) {
foreach ($images as $image) {
$searchQuery = '%' . basename($image->path) . '%';
$inPage = DB::table('pages')
->where('html', 'like', $searchQuery)->count() > 0;
+
$inRevision = false;
if ($checkRevisions) {
$inRevision = DB::table('page_revisions')
diff --git a/resources/lang/en/settings.php b/resources/lang/en/settings.php
index dce345426..3e043e3c6 100755
--- a/resources/lang/en/settings.php
+++ b/resources/lang/en/settings.php
@@ -68,7 +68,7 @@ return [
'maint' => 'Maintenance',
'maint_image_cleanup' => 'Cleanup Images',
'maint_image_cleanup_desc' => "Scans page & revision content to check which images and drawings are currently in use and which images are redundant. Ensure you create a full database and image backup before running this.",
- 'maint_image_cleanup_ignore_revisions' => 'Ignore images in revisions',
+ 'maint_delete_images_only_in_revisions' => 'Also delete images that only exist in old page revisions',
'maint_image_cleanup_run' => 'Run Cleanup',
'maint_image_cleanup_warning' => ':count potentially unused images were found. Are you sure you want to delete these images?',
'maint_image_cleanup_success' => ':count potentially unused images found and deleted!',
diff --git a/resources/views/settings/maintenance.blade.php b/resources/views/settings/maintenance.blade.php
index 13a8930a1..941a258d8 100644
--- a/resources/views/settings/maintenance.blade.php
+++ b/resources/views/settings/maintenance.blade.php
@@ -41,9 +41,9 @@
@else
-