kooba/craft-content-audit

Content audit tools for Craft CMS — detect orphaned assets, broken entry references, duplicate slugs, and more.

Maintainers

Package info

github.com/ignacioisas9/craft-content-audit

Type:craft-plugin

pkg:composer/kooba/craft-content-audit

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-06-23 05:53 UTC

This package is auto-updated.

Last update: 2026-06-23 06:08:13 UTC


README

Audit your Craft CMS 5 content for common issues. Currently detects:

  • Orphaned Assets — files uploaded to a volume that aren't referenced by any entry
  • Missing Alt Text — images that have no alt text set
  • Large Assets — files over 2 MB (warning) or 5 MB (critical); threshold configurable via config/content-audit.php
  • Broken References — entries whose relational fields point to disabled or deleted elements

Results are stored in the database and persist between page loads. Each issue links directly to the offending element in the Control Panel.

Installation

Via Composer (local dev)

  1. Clone this repo alongside your Craft project.

  2. In your Craft project's composer.json, add the repository and require the plugin:

{
    "repositories": [
        {
            "type": "path",
            "url": "../craft-content-audit"
        }
    ],
    "require": {
        "iistudio/craft-content-audit": "*"
    }
}
  1. Run:
composer update iistudio/craft-content-audit
php craft plugin/install content-audit
  1. The Content Audit item will appear in your CP sidebar.

Via Plugin Store (once published)

Search for "Content Audit" in the Craft Plugin Store and click Install.

Usage

  1. Go to Content Audit in the Control Panel sidebar.
  2. Click Run Audit.
  3. Review the results table. Each issue links directly to the offending element so you can fix or delete it.

Extending

Adding a new auditor is straightforward:

  1. Create a class in src/auditors/ implementing AuditorInterface:
class MyNewAuditor implements AuditorInterface
{
    public function handle(): string { return 'my-check'; }
    public function label(): string  { return 'My Check'; }
    public function run(): array     { /* return AuditIssue[] */ }
}
  1. Register it in AuditService::init():
$this->auditors = [
    new OrphanedAssetsAuditor(),
    new MyNewAuditor(),   // <- add here
];

That's it — the CP table picks it up automatically.

Plugin Store Submission Checklist

  • Hosted on GitHub (public repo)
  • CHANGELOG.md kept up to date
  • Icon at icon.svg (square SVG, ideally 150×150)
  • composer.json extra.craftcms.plugin fields complete
  • Developer account at id.craftcms.com
  • Plugin submitted at plugins.craftcms.com/new

Craft Plugin Store review typically takes a few business days.

Craft 5 Development Notes

Controllers: Do not use requireCpAccess() — it doesn't exist in Craft 5. Use this pattern instead:

protected array|int|bool $allowAnonymous = self::ALLOW_ANONYMOUS_NEVER;

public function actionIndex(): Response
{
    $this->requireLogin();
    // ...
}

Twig templates: Never put double quotes inside a double-quoted string. If the string contains "quotes", use single quotes for the outer string:

{# Wrong — breaks Twig parser #}
{{ "Click "Run" to start"|t('plugin') }}

{# Correct #}
{{ 'Click "Run" to start'|t('plugin') }}

Requirements

  • Craft CMS 5.0+
  • PHP 8.2+

License

Craft — see LICENSE.md