The script deletes all Gallery3x content of all resources with the given template: images with thumbnails, file attachments, videos with covers, embeds — database records and files on disk. Deletion goes through the component's processors, like the “Delete all” button in the manager.
Deleted content cannot be restored. Back up the database and the media source folder before running it.
Running
From the site root, the template ID is the first argument. First with --dry-run (only show what will be deleted):
php core/components/gallery3x/cli/clear_by_template.php 12 --dry-run
php core/components/gallery3x/cli/clear_by_template.php 12
Without a template ID the script prints a hint and does nothing. Not available over HTTP (403).
When you need it
- A template no longer uses the gallery, but the files take up space.
- A failed import from ms2Gallery — clean up and run it again.