Page MenuHomePhabricator

Magic word to set PageImages
Open, Stalled, Needs TriagePublicFeature

Description

Feature summary

Introduce a new magic word to allow manual, explicit setting of a page’s PageImages thumbnail directly in wikitext. Suggested wording would be, by way of example:

{{#pageimage: Example.jpg}}

This acts as a hard override, telling PageImages to use (in this example) File: Example.jpg as the page’s representative image for search results, mobile view, page previews, and any other PageImages instances.

Use case(s) and Benefits

• Lets editors choose a specific thumbnail when PageImages’ automatic selection is unsuitable (decorative lead images, irrelevant gallery items, tiny icons, NSFW images(?), etc.).
• Avoids template hacks such as inserting a dummy lead image purely to satisfy#PageImages.
• Improves search UX by ensuring that key articles display meaningful, recognisable thumbnails rather than arbitrary or missing images.
• Reduces editor confusion: PageImages’ current behaviour is often opaque, and a magic word provides a clear, explicit instruction.
• Mirrors the logic of other magic‑word overrides (e.g., {{DISPLAYTITLE}}), making the behaviour intuitive for experienced editors.
• Would allow the manual workarounds of a large number of the bugs listed in https://phabricator.wikimedia.org/project/board/731/
• Would also allow fixing of bugs like T432710: Social media cards crop images poorly with additional parameters e.g. {{#pageimage: Example.jpg|crop=bottom}}

Event Timeline

Vesperio_ofc subscribed.

Hii,
I'd like to work on this task

Change #1340495 had a related patch set uploaded (by CoderAnimeshPathak; author: CoderAnimeshPathak):

[mediawiki/extensions/PageImages@master] Introduce {{#pageimage:}} magic word

https://gerrit.wikimedia.org/r/1340495

Hello @Bugreporter2 ,
I want to just clarify that for the magic word syntax, I've currently registered it to support both {{#pageimage:}} (with the hash) and {{pageimage:}} (without). Is there a strong preference for standardizing on one over the other?

Aklapper changed the task status from Open to Stalled.Sep 12 2026, 11:04 AM

Can you please elaborate why https://www.mediawiki.org/wiki/Extension:PageImages#Can_I_request_an_explicit_page_image%3F not sufficient?
I don't understand why this ticket requests another solution to a potentially already solved problem.

It is already possible to select a image to use as PageImage by adding pageimage class to it. Is there really a case where we would want to use and image that isn't part of the article as page image?

Can you please elaborate why https://www.mediawiki.org/wiki/Extension:PageImages#Can_I_request_an_explicit_page_image%3F not sufficient?
I don't understand why this ticket requests another solution to a potentially already solved problem.

It is already possible to select a image to use as PageImage by adding pageimage class to it. Is there really a case where we would want to use and image that isn't part of the article as page image?

Thanks for the comments. They are reasonable questions to ask, and it's best if we have important discussions like this before someone jumps in and spends time trying to fix it.

The inline image and the PageImages thumbnail aren’t completely unrelated, but the link between them is structural rather than conceptual: the image is placed in the article to be shown to readers, while the PageImages thumbnail is page‑level metadata used by search, previews, and external tools. When one is made to control the other, you end up with a slightly awkward coupling between layers that don’t really belong together, and it begins to resemble the kind of accidental cross‑layer dependency (Technical-Debt). MediaWiki normally keeps content and metadata separate, e.g. DISPLAYTITLE and DEFAULTSORT exist as explicit page‑level instructions.

Furthermore, I think this offers a better syntax for fixing other bugs related to cropping or selection, as it’s cleaner and more self‑contained than piggy‑backing on an image.

There may also be use cases for setting the page image of thumbnail separately from the main page image. It does give more control over this.

Change #1340495 abandoned by CoderAnimeshPathak:

[mediawiki/extensions/PageImages@master] Introduce {{#pageimage:}} magic word

https://gerrit.wikimedia.org/r/1340495