GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Edit Task
  • Edit Related Tasks...
  • Create Subtask
  • Edit Parent Tasks
  • Edit Subtasks
  • Merge Duplicates In
  • Close As Duplicate
  • Edit Commits
  • Edit Mocks
  • Mute Notifications
  • Protect as security issue
  • MediaWiki-Parser
  • (Backlog)
  • MediaWiki-File-management

This view

  • Original page
  • New address

GeezerVison is showing phabricator.wikimedia.org — T247680 Allow em values for image size

Page MenuHomePhabricator
Log In
Create Task
Maniphest T247680

Allow em values for image size
Open, Needs TriagePublicFeature
Actions

  • Edit Task
  • Edit Related Tasks...
  • Create Subtask
  • Edit Parent Tasks
  • Edit Subtasks
  • Merge Duplicates In
  • Close As Duplicate
  • Edit Related Objects...
  • Edit Commits
  • Edit Mocks
  • Mute Notifications
  • Protect as security issue
Assigned To
None
Authored By
Dvorapa
Mar 14 2020, 9:30 PM2020-03-14 21:30:53 (UTC+0)
Project Tags
  • MediaWiki-Parser (Backlog)
  • MediaWiki-File-management (Backlog)
  • Commons (Incoming)
Referenced Files
None
Subscribers
Aklapper
Bawolff
Bugreporter2
Dvorapa
Frostly
Izno

Description

You can use em values to size tables, infoboxes and some other stuff, but not for images. This is crucial as skins can differ their base font size (13, 14, 16 px) and images in em-sized infoboxes then overflow.

See also T247682 for alternative solution.

Currently, images on MediaWiki pages can only be resized using pixels (px). This limitation can be problematic for in-line images, especially for those meant to resemble or replace text characters that are unavailable in Unicode (e.g., unique glyphs like a question comma or Prince's "Love Symbol" glyph). Additionally, some templates, like [[template:nospam]], use images to obscure characters (such as @) to prevent email-harvesting bots from recognizing email addresses.

When an image is used in-line, it doesn't adjust its size to match surrounding font changes. For instance, it remains the same size when page font is adjusted, or if <big> or <small> tags are used, which can disrupt visual coherence.

However, HTML embedded with CSS does allow an image's size to be set using em units, which scales the image relative to the surrounding text's font size. One em is the width of a letter M. Implementing support for em-based image scaling within MediaWiki would enable in-line images to grow or shrink in tandem with text, improving consistency across varying font sizes.

It's usual for such sizing to be quite small, e.g. 0.35em

Here's a quick-and-dirty example of how this can be implemented in html:

<img src="character.png" style="width: 0.5em; height: auto;" alt="Character representation">

and how this could be called in wikitext:

[[image:character.png|0.5em|character representation]]

Benefits:

  • Provides greater flexibility and consistency for in-line image usage.
  • Enhances readability and visual alignment in text-heavy contexts where the image should match text size (such as in academic or linguistic content).
  • Offers a valuable tool for templates or icons embedded in text that need to adjust dynamically to the viewer's preferred font settings.

Notes

The file that should be changed is includes/media/MediaTransformOutput.php.

Related Objects

  • Mentions
  • Duplicates
Mentioned In
T247682: Add {{em}} magic word
Mentioned Here
T113101: Images should be responsive in Vector and restrained to a max-size.
T247682: Add {{em}} magic word
Duplicates Merged Here
T379593: Allow image resizing using em (fontsize-relative) units

Event Timeline

Dvorapa created this task.Mar 14 2020, 9:30 PM2020-03-14 21:30:53 (UTC+0)
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 14 2020, 9:30 PM2020-03-14 21:30:53 (UTC+0)
DannyS712 changed the subtype of this task from "Task" to "Feature Request".Mar 14 2020, 9:34 PM2020-03-14 21:34:24 (UTC+0)
Dvorapa renamed this task from Allow em values of image size to Allow em values for image size.Mar 14 2020, 9:38 PM2020-03-14 21:38:01 (UTC+0)
Dvorapa mentioned this in T247682: Add {{em}} magic word.
Dvorapa updated the task description. (Show Details)
Pppery edited projects, added: MediaWiki-Parser, MediaWiki-File-management; removed: MediaWiki-Page-editing.Feb 11 2025, 4:29 PM2025-02-11 16:29:29 (UTC+0)
Pppery merged a task: T379593: Allow image resizing using em (fontsize-relative) units.
Pppery added subscribers: Bugreporter2, Izno, Frostly.
Maintenance_bot added a project: Commons.Feb 11 2025, 4:30 PM2025-02-11 16:30:37 (UTC+0)
Bugreporter2 updated the task description. (Show Details)Feb 12 2025, 12:20 PM2025-02-12 12:20:23 (UTC+0)
Bugreporter2 awarded a token.
Izno added a comment.Mar 4 2025, 9:22 PM2025-03-04 21:22:02 (UTC+0)
Comment Actions

The suggestion will likely cause reflow in skins with different font sizes where those font sizes happen not to match the arbitrary pixel value that you must output for an image. (And it will still cause pain for setting responsive images, as it does today, see e.g. the !importants that have to be dropped on image CSS for low resolution screens as has been implemented in T113101 and elsewhere.)

That also ignores yet another way to overload the image syntax which is already notably difficult to parse (based on all the false positives the linter throws up for invalid image syntax that certain contributors routinely run into).

I am unconvinced that this is a good path forward or that it makes sense in the context of the wider web.

Bugreporter2 added a comment.Mar 13 2025, 8:29 AM2025-03-13 08:29:23 (UTC+0)
Comment Actions

Thanks for your comments @Izno

I'm not sure that I understand what you mean by:

The suggestion will likely cause reflow in skins with different font sizes where those font sizes happen not to match the arbitrary pixel value that you must output for an image.

Could you please provide an example of how that might manifest itself? I don't follow your reasoning. It may be that you've misunderstood the logic here. Either that or I'm being stupid.

Bugreporter2 updated the task description. (Show Details)Sep 22 2025, 1:31 AM2025-09-22 01:31:18 (UTC+0)
Bawolff subscribed.Sep 22 2025, 2:34 AM2025-09-22 02:34:37 (UTC+0)
Comment Actions

I'm pretty unconvinced by the usecases for this. The usecase seems fairly niche and not worth the complexity. On the rare occasion this would be useful, i think templatestyles is sufficient to handle it.

Log In to Comment
Content licensed under Creative Commons Attribution-ShareAlike (CC BY-SA) 4.0 unless otherwise noted; code licensed under GNU General Public License (GPL) 2.0 or later and other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL · Credits
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.