Page MenuHomePhabricator

Enable PageImages on Commons categories namespace
Closed, ResolvedPublic

Description

At, e.g., https://commons.wikimedia.org/w/index.php?title=Category:San_Francisco&action=info there is currently no page image, despite the commons category having an infobox with a main image. That means that when a link to the commons category is shared on twitter/facebook etc., no image is shown as there is no og:image meta tag.

It looks like this might be as straightforward as changing $wgPageImagesNamespaces to include categories.

Event Timeline

Deskana added a subscriber: Ramsey-WMF.

Perhaps @Ramsey-WMF might want to take a look at this.

Jdlrobson subscribed.

Lemme know if the config change doesn't resolve this. If it doesn't I can arrange some further investigation from our side.

Isnt it adding a Twitter Cards what should be done?

<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@WikiCommons" />
<meta name="twitter:title" content="Category: San Francisco" />
<meta name="twitter:description" content="Media about the Consolidated city-county in California, United States" />
<meta name="twitter:image" content="https://commons.wikimedia.org/wiki/Category:San_Francisco#/media/File:San_Francisco_(Evening).jpg" />

Maybe the Template Infobox Wikidata could create those meta tags?

Isnt it adding a Twitter Cards what should be done?

I think PageImages does this in a more generic way that works with all services, through OpenGraph ('og:image'), but I could be wrong.

The meta tags need to be in the page header, and the infobox can only add content to the page body, so the infobox can't add the tags.

Change 446257 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[operations/mediawiki-config@master] PageImages: Make it possible to add extra namespaces

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

Change 446257 merged by jenkins-bot:
[operations/mediawiki-config@master] PageImages: Make it possible to add extra namespaces

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

Mentioned in SAL (#wikimedia-operations) [2018-08-06T23:38:11Z] <jforrester@deploy1001> sync-file aborted: SWAT PageImages: Add NS_CATEGORY for Commons T198716 (duration: 00m 04s)

Change 450885 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[operations/mediawiki-config@master] Re-apply "PageImages: Add NS_CATEGORY for Commons"

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

I'm assuming this is the culprit for this error I'm seeing in logstash?
Warning: Invalid operand type was used: array_flip expects an array or collection in /srv/mediawiki/php-1.32.0-wmf.15/extensions/PageImages/includes/ParserFileProcessingHookHandlers.php on line 123

Change 579067 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[operations/mediawiki-config@master] Enable PageImages on Commons categories

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

^ is there any reason why this would not work?

Change 579067 abandoned by Jdlrobson:
Enable PageImages on Commons categories

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

Jdlrobson renamed this task from Enable PageImages on Commons categories to Enable PageImages on Commons categories namespace.Jun 18 2020, 4:58 PM
Jdlrobson removed a project: PageImages.
Jdlrobson added a subscriber: ovasileva.

@Mike_Peel is this still needed? If so @Ramsey-WMF is this something your team or our team (@ovasileva ) could look into?

@Mike_Peel is this still needed? If so @Ramsey-WMF is this something your team or our team (@ovasileva ) could look into?

Yes. I've just tested it on Facebook - if you share https://en.wikipedia.org/wiki/San_Francisco then you see an image but if you share https://commons.wikimedia.org/wiki/Category:San_Francisco then you don't. I also tried on Twitter, but I couldn't actually get either link to show an image there...

Change 621306 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[operations/mediawiki-config@master] Configure namespaces on commons to include categories

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

Change 621306 merged by jenkins-bot:
[operations/mediawiki-config@master] Configure namespaces on commons to include categories

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

Mentioned in SAL (#wikimedia-operations) [2020-08-19T18:24:47Z] <urbanecm@deploy1001> Synchronized wmf-config/InitialiseSettings.php: bb4aa44b0bd5b2b33d190d3af81e038e5fc55e3f: Configure namespaces on commons to include categories (T198716) (duration: 01m 04s)

Jdlrobson claimed this task.

Note this is enabled but comes with a big caveat - a page image is only derived from images within a page, not the pages from categories.
The image for the page image must be inside the article itself
e.g.
https://commons.wikimedia.org/wiki/Category:Coats_of_arms_of_presidents_of_Chile?action=info

Note this is enabled but comes with a big caveat - a page image is only derived from images within a page, not the pages from categories.
The image for the page image must be inside the article itself
e.g.
https://commons.wikimedia.org/wiki/Category:Coats_of_arms_of_presidents_of_Chile?action=info

Thanks! Will it also support images included through templates in the page? E.g. at:
https://commons.wikimedia.org/w/index.php?title=Category:South_Pole_Telescope&action=info
it doesn't report an image yet, even though the infobox is there, but maybe that's a caching issue.

Also, if there is any extra mark-up I could add to the infobox to help flag the right image to use, please let me know!

In theory, yes, but there may be caveats with Lua templates.
Note the page images algorithm may also considers various elements of the image unsuitable and not use them.

Please see https://www.mediawiki.org/wiki/Extension:PageImages#How_does_it_select_images?

You'll also need to make a non-null edit the page and wait for the new page image to apply.

It looks like that particular category page has an image now.

Fantastic, thank you! I'll check more cases in the next few days, and will post back here if I find any issues.

I've tested this a bit, and it looks like null edits do update the page info, e.g. at https://commons.wikimedia.org/w/index.php?title=Category:Lovell_Telescope&action=info . I've also posted a notice about this at https://commons.wikimedia.org/wiki/Commons:Village_pump#PageImages_enabled_for_categories .

I'm not sure if this solves the issue with Twitter cards, though, that might need a separate investigation.

Also, at https://commons.wikimedia.org/w/index.php?title=Category:San_Francisco&action=info the page image was added via changing the image on Wikidata so it wasn't a panoramic one and then doing a null edit to the category - the actual edits to the page didn't change anything while the image was still a panoramic one.

I'm not sure if this solves the issue with Twitter cards, though, that might need a separate investigation.

There's no image in:

https://twitter.com/pigsonthewing/status/1296519144238657537 despite the mentioned category only being created at 22:32 (UK time), 19 August 2020

There's no image in:

https://twitter.com/pigsonthewing/status/1296519144238657537 despite the mentioned category only being created at 22:32 (UK time), 19 August 2020

Please see T157145. To be clear this task may improve sharing functionality for category pages but it won't solve it until that task is taken care of. It should help with Facebook shares:
Relevant links: