API / Minn\Media / Icons

Icons final class

Minn\Media\Icons · public/minn/src/Minn/Media/Icons.php · 68 lines

The icon a file type is shown with, as wp_mime_type_icon finds it (probe plugin-helpers): the icon folders (core's wp-includes/images/media, and any icon_dirs adds) read once a request into a name => address map, an icon of the asked kind (.png or .svg) preferred where both exist; then the first name the type answers to: an attachment's file extension and the kind of file it is, the type, its two halves, the type with an underscore for the slash. Nothing answering (a post that is not there, a type that is empty) is the default icon.

Constants and properties

privateCORE = array ( 0 => 'archive', 1 => 'audio', 2 => 'code', 3 => 'default', 4 => 'document', 5 => 'interactive', 6 => 'spreadsheet', 7 => 'text', 8 => 'video', )

Core's icons, each kept as .png and .svg.

Public

staticforType(string|int $mime, string $preferred): string|false#

The icon's address for a type or an attachment id.

Internals 2

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatemap(string $preferred): array#

Every icon by name, read once a request with the first asker's preferred kind. @return array<string, string>

@return array<string, string>
privatefiles(string $dir, string $coreDir, string $preferred): array#

A folder's icons by name; core's are known, a plugin's folder is read. @return array<string, string>

@return array<string, string>