- Issue created by @sime
From a site building perspective it's very common to focus attention on the media types, both from a content management and a theming perspective. So it's common to have "document" media type that allows a single file, however theming this with just core, say showing and icon for the file mime, file url, a file size, and the media name is surprisingly complex. Some considerations are:
1. File formats such as Generic File are ignorant of the media name.
2. Accessing the file elements from the media template is relatively complex, being a field list of entities on a field
3. The field the files are on can change
4. Examples you find on the web often need to focus on multiple files, and can be confusing.
5. There are many modules, but it feels like they shouldn't be needed.
Surface the following twig variables into the media template by default. Obviously naming is a challenge, and how to delineate between what is meta and what is renderable.
file_entity.single_file
Has a single file (any twig examples should check this)file_entity.size
First file sizefile_entity.mime
First file mime (note that mime class is output in attributes of File entities)file_entity.filename
file_entity.uri
...
Alternatively:
file_meta.count
Number of files (or just test for length) file_meta.N.size
file_meta.N.name
file_meta.N.filename
I wonder should a site builder be able flag that a media bundle should surface information about a primary file, or if there is enough logic to do this automatically.
Active
11.0 π₯
Last updated