Page MenuHomePhabricator

Allow retrieving/getting page image file name from wikitext using Scribunto/Lua or parser function or something
Open, Needs TriagePublic

Description

There should be a way to retrieve the page image of the article "White House" from the article "Barack Obama". In the case of "White House", we want to be able to retrieve the string "File:White House north and south sides.jpg" so that it can be used in embedding.

Editors would be able to easily re-use this image string in wrapper templates to auto-include the image and a link to the associated article. This would be useful in "See also" sections of articles and in lists. I imagine we'd find some other creative uses for it as well.

I don't think batching is needed for a first pass implementation (this feature could initially be marked as "expensive"), but if it's not crazy difficult to implement, batching would be preferable.

Potential implementation options:

  • a parser function such as {{#getpageimage:Page title}}
  • a Scribunto/Lua function

See also

Event Timeline

MZMcBride created this task.Apr 6 2016, 6:08 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 6 2016, 6:08 AM

I really don't like all of these recent ideas to let Lua fetch information about pages that isn't known until the page is parsed.

I really don't like all of these recent ideas to let Lua fetch information about pages that isn't known until the page is parsed.

MZ and I discussed on IRC that we could only allow lookups of *other* pages so you'd never run into the issue of trying to depend on something that is determined in the current parse.

I really don't like all of these recent ideas to let Lua fetch information about pages that isn't known until the page is parsed.

MZ and I discussed on IRC that we could only allow lookups of *other* pages so you'd never run into the issue of trying to depend on something that is determined in the current parse.

That feels clunky, though, and it doesn't completely fix the problem. If page A referenced page B and page B referenced page A, you'd still get the same issue.

That feels clunky, though, and it doesn't completely fix the problem. If page A referenced page B and page B referenced page A, you'd still get the same issue.

I don't follow. It should be possible to programmatically retrieve attributes/properties of a wiki page such as page length in bytes, display title, page image, etc. via parser functions or via Scribunto/Lua, in my opinion. I'm not sure how we'd have circular references with page images.

Looking at https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Title_objects, extending a title object to support retrieving a few additional properties seems reasonable. As Lego says, we're talking about retrieving info about other pages, so it should be less volatile.