Bricks version: 2.4.3
What happens The usage check before “Trash” / “Delete permanently” in the Media Browser reports 0 uses for files that Bricks itself still references, so they count as safe to delete:
- a popup background or sticky header scrolling background (template settings)
- a custom font file (Custom Fonts → font faces)
- a custom icon (Icon Manager → custom icon set)
- an image inside a global element (deprecated, but still rendered until converted)
- an image on a page that is in the trash: deleting it and restoring the page leaves a broken image
Expected These references are listed like an image element on a page. The Academy names URL-only references, custom CSS, code elements, editor content and custom fields as not covered — these five are Bricks’ own data.
Steps to reproduce
- Popup template → Template settings → Popup → Background: pick an image.
- Media Browser → select that image → Delete permanently.
- The check shows the image as not in use.
Same with a font face file, a custom icon, a global element, or a page with an image element that was moved to the trash. Checked with Media_Browser_Bulk::get_attachment_usage_summary(): 0 for all of them, 1 for the same image element on a published page.
Cause includes/media-browser-bulk.php, get_usage_summary():
// ~:1141 — no BRICKS_DB_TEMPLATE_SETTINGS, no BRICKS_DB_CUSTOM_FONT_FACES
foreach ( [ 'BRICKS_DB_PAGE_HEADER', 'BRICKS_DB_PAGE_CONTENT', 'BRICKS_DB_PAGE_FOOTER', 'BRICKS_DB_PAGE_SETTINGS' ] as $constant_name ) {
// ~:1189 $global_sources — no BRICKS_DB_CUSTOM_ICONS, no BRICKS_DB_GLOBAL_ELEMENTS
'BRICKS_DB_GLOBAL_CLASSES' => [ … ], 'BRICKS_DB_THEME_STYLES' => [ … ], 'BRICKS_DB_COMPONENTS' => [ … ],
// collect_post_usage_from_database() ~:1341 — trashed posts are skipped
AND p.post_status NOT IN (%s, %s, %s) // 'inherit', 'trash', 'auto-draft'
Suggested fix
- Scan
BRICKS_DB_TEMPLATE_SETTINGSandBRICKS_DB_CUSTOM_FONT_FACESas post meta,BRICKS_DB_CUSTOM_ICONSandBRICKS_DB_GLOBAL_ELEMENTSas options — and add them toget_usage_meta_keys()/get_usage_option_keys()too, which invalidate the confirmation. - Font faces store bare IDs (
[ '400' => [ 'woff2' => 123 ] ]), whichcollect_attachment_references()does not count (onlyidin a media context orattachmentId/attachment_id) — the format keys need to count as IDs there. - Count trashed posts, maybe labelled “in trash” in the review.
Happy to provide more details if that helps.
Best Regards
Suat