Page MenuHomePhabricator

Use thumbnail preferences for thumbnail of Commons media file
Closed, ResolvedPublic

Description

Items like https://www.wikidata.org/wiki/Q27697316 display a thumbnail on Wikidata. The size of these thumbnails seems to be static and rather small hardcoded to 150px it seems ( https://upload.wikimedia.org/wikipedia/commons/thumb/2/21/Piombo_cristo_cruz_prado.jpg/150px-Piombo_cristo_cruz_prado.jpg ). In my preferences at https://www.wikidata.org/wiki/Special:Preferences#mw-prefsection-rendering I can set thumbnail from 120px to 400px. This should be used so a user can change it.

The thumbnail user preference can be retrieved through https://www.wikidata.org/w/api.php?action=query&meta=userinfo&uiprop=options&output=json . It looks like it returns an integer from 0 (120px) to 7 (400px) in the field "thumbsize".

Time-boxed to 4h for investigation of how to by-pass parser-cache for those images.

Event Timeline

Lydia_Pintscher moved this task from incoming to ready to go on the Wikidata board.
Lydia_Pintscher added a subscriber: hoo.

@hoo any reasons we didn't take that setting into account?

I took a look at this, it's not hard to implement and it doesn't pollute the ParserCache if we get the thumbnail size from ParserOptions. That should be easy.

@Ladsgroup: Have you had a chance to investigate the bypassing the parser cache? Any findings to share?

@Ladsgroup: Have you had a chance to investigate the bypassing the parser cache? Any findings to share?

Yes, I'm on it. The main issue is that ParserOptions are passed to data type parsers but we need this in the formatter.

I got it to work but I could do only by injecting global variables into CommonsInlineImageFormatter, I quite dislike this solution but I couldn't find any way around it that doesn't involve refactoring half of mediawiki core and wikibase. One quite expensive way to do this is to define CommonsMedia value type, inject the thumbsize in the value type (by defining CommonsMediaValueParser that takes ParserOptions) and then use it in the CommonsInlineImageFormatter, that would be two days of work at least. Unless I'm missing something obvious

Change 528497 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/Wikibase@master] Use thumbnail preferences for thumbnail of Commons media file

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

One quite expensive way to do this is to define CommonsMedia value type, inject the thumbsize in the value type (by defining CommonsMediaValueParser that takes ParserOptions) and then use it in the CommonsInlineImageFormatter, that would be two days of work at least. Unless I'm missing something obvious.

Is it only expensive in terms of development time? if so, two days are not all that expensive given that this solution will probably avoid other less ideal workarounds + it is a bit of good refactoring.

One quite expensive way to do this is to define CommonsMedia value type, inject the thumbsize in the value type (by defining CommonsMediaValueParser that takes ParserOptions) and then use it in the CommonsInlineImageFormatter, that would be two days of work at least. Unless I'm missing something obvious.

Is it only expensive in terms of development time? if so, two days are not all that expensive given that this solution will probably avoid other less ideal workarounds + it is a bit of good refactoring.

It can be more than two days, I would say at least, not to mention the review and other bits. Plus I'm not sure it's conceptually correct. For monolignual text, the language code is part of that value. It makes sense but for commons media value type, I don't think its thumb size would be a good fit for the value.

Change 528497 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Use thumbnail preferences for thumbnail of Commons media file

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