Skip to main content

Module media_usage

Module media_usage 

Source
Expand description

Which media-library pictures and files are in use, and where.

A picture can be referenced from a page’s code extension row, from its page-builder data (fields, blocks, and the items of list blocks such as Cards, Slider and Gallery), from a library element, or from a site setting (Branding’s logo and icon, a theme’s footer badge). Each holds the media id under a field whose name the schema decides (cover, image, logo, …), so this first learns those names from every schema that can hold a picture (media_fields) and then scans the stored values for them.

The Unused media report and a picture’s Used on panel both read from here, so they always agree.

Enums§

Use
Where a picture is used.

Functions§

collect
The media ids value references through names fields. A string that holds JSON (stream bodies stored as text) is read too.
media_fields
Names of the fields that hold a media id, across every schema that can hold one: built-in and registered blocks, page-builder page types and components, and site-setting forms. Code page types keep the older media_id / *_media_id convention, matched in [is_media_field].
used
Ids of every picture or file in use anywhere.
uses_of
Where one picture or file is used.