keyagency/statamic-asset-usage
Statamic addon that tracks where assets are used across your content, helping you see references before deleting or replacing files and keeping asset management safer and more informed.
Start with the config file and the PDF export route/controller — those two files explain most of the package's behaviour. Publish config and migrations, run migrate, then seed or upload a handful of assets so the Overview page has something to show.
Key config keys to locate first:
First practical use case: open the Overview page, apply a filter, and export the filtered set to PDF. That single flow exercises filtering, thumbnail generation, chunked export, and the browser-side merge — if it works end to end, the rest of the package will behave predictably.
For a first integration, call the export from your own controller with a filter payload rather than building a bespoke export route; reusing the package's filter object is what keeps the PDF and the on-screen list in sync.
Reuse one filter definition for list and PDF. The most common source of "the PDF doesn't match the screen" bugs is duplicating filter logic. Build the filter once (query scope, form request, or filter object) and pass it to both the Overview listing and the PDF export endpoint.
Treat the PDF export as a chunked protocol, not a single call. With parts of 500, a 10,000-asset export is ~20 sequential requests that the browser stitches into one file. Design around that:
?page=N&per_page=500) with a stable orderBy so parts never overlap or skip rows.Queue the heavy parts when exports are user-triggered. If your asset records are large or thumbnails are generated on demand, the first part of an export is much slower than the rest (cold thumbnail cache). Warming thumbnails for the filtered set before starting the export keeps the browser loop snappy and avoids per-part timeouts.
Lean on the smaller thumbnails. The reduced thumbnail footprint means you can afford a slightly higher thumbnail quality setting than before at the same PDF size. If your PDFs are image-heavy, tune quality up rather than dimensions up — dimension changes alter the print layout.
Wire the export into both Overview and Compression pages using the same endpoint; only the filter payload differs. This is the pattern the v1.7.0 filter-width fix implies the package expects.
Test at the seams. Assert part counts for a known dataset, assert parts are disjoint (no duplicated IDs across pages), and assert an unauthorized part request is rejected — those three tests catch most regressions in a chunked exporter.
orderBy, chunks can duplicate or drop rows when the underlying data changes mid-export. Always sort by a unique column last.Content-Security-Policy or inside an iframe, verify blob: URLs and any worker usage are permitted — this fails only in production configurations.config:cache refresh and a hard refresh on the front end if the chunk size is also embedded in JS.How can I help you explore Laravel packages today?