GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||
GeezerVison is showing phabricator.wikimedia.org — T247680 Allow em values for image size
Assigned To None Authored By
Referenced Files None
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:
Notes The file that should be changed is includes/media/MediaTransformOutput.php.
Related Objects Event TimelineRestricted 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) 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) Bugreporter2 updated the task description. (Show Details)Feb 12 2025, 12:20 PM2025-02-12 12:20:23 (UTC+0) Bugreporter2 awarded a token. 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. Comment Actions Thanks for your comments @Izno I'm not sure that I understand what you mean by:
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) 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. 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. |