Page MenuHomePhabricator

New magic word on Wikimedia Commons for file type
Open, Needs TriagePublicFeature

Description

Feature summary
My proposal is to add a new Magic word (like {{PAGENAME}}) that would return the type of a file (audio, image, text, video).

The magic word would be eg. {{FILETYPE}}
(I couldn't find anything that matches in the list of magic words)

Use case(s)
The magic word can be used on templates differ behave different for different file types (eg. adding different categories for images and videos)

On Wikimedia Commons there is the template {{File type en}}, but it just decides based on the file extension and not the actual type.
Example: An .ogg file is an audio file no matter what the real file is. File:2026 Rupertikapelle Postelgraben Mittagsglocken 01**.ogg** is a .ogg file, yet it's a video and not an audio file. (Maybe the file extension should be .ogv in this case, but it works so I think it's fair to assume that there are more files like it)
According to Commons:Project scope/Allowable file types "New software supports file extension .ogv for Theora video without or with Vorbis audio, RFC 3534 .ogg is still usable instead of RFC 5334 .ogx for Theora video with other Ogg audio codec". Therefore there is no way to tell by the file extension alone whether the file is an audio or a video file.

Benefits
The return value would be correct regardless of the file extension.

Example: Using {{Taken on}} on a file like 2026 Rupertikapelle Postelgraben Mittagsglocken 01.ogg is not possible as it is auto-categorised as audio file (because of .ogg) even it clearly is a video file.

Event Timeline

We could show the types mentioned on https://www.mediawiki.org/wiki/Media_type, but that wouldn't match the types mentioned in this description. Maybe we could map the BITMAP and DRAWING to the "image"?

image.png (1,112×287 px, 33 KB)

Bugreporter2 subscribed.

But if the output is image, surely you want to distinguish the type of image (jpeg, tif, etc)?

You can already get the mime type via lua. Wouldn't that solve this problem?

You can already get the mime type via lua. Wouldn't that solve this problem?

It might, but it still leaves a capability gap in the vanilla-flavour standard MediaWiki installation as it doesn't come with modules, but instead these have to be written from scratch (or more likely copied from other wikis).

I'm opposed to this unless there is a clear, non-hypothetical use case that applies more broadly than just commons