Page MenuHomePhabricator

Add an image: show suggestion-specific content in image inspector
Open, MediumPublic


  • Suggestion reason T292467: Add an image: suggestion reason
  • Image thumbnail
    • On the left under the suggestion reason.
    • Show a small version of the suggested image. It should always fit into the same horizontal rectangle, even if that means letterboxing it (like for a portrait-shaped image).
    • In the lower right of the thumbnail should be an icon to expand the image to fullscreen. The icon floats above the thumbnail with transparent gray, so you can still see the image underneath it.
    • Tapping anywhere on the thumbnail (not just the icon) makes the image full screen. See T290540: Add an image: image viewer.
  • Image metadata
    • On the righthand side of the thumbnail should be a set of image metadata from Commons.
      • Filename: in black bold, including the extension (e.g. ".jpg"). It only has one line. It should not be a link or have the "open in another window" button. If the filename is too long, it should have a "...".
      • Description: below the filename, show as much of the description from Commons as will fit. If it is too long, it should be cut off with "..." This is not the "caption" -- it is the free text description that is entered along with almost every image. In future iterations, we may want to have fallback logic to display caption if description is unsatisfactory, or vice versa. But for this first iteration, we should just use description.
    • After the description, there should be a blue link that says "View details". This link should open the "image details dialog". See T290782: Add an image: image details. This line should begin with a blue "i" icon. If this does not all fit on one line, it should be truncated with "...".

Mockups as of 2021-10-08:

image.png (1×766 px, 631 KB)

NOTE: Refer to Figma for up-to-date detailed redline mocks and specs:

Event Timeline

mewoph renamed this task from Add an image: show suggestions-specific content in image inspector to Add an image: show suggestion-specific content in image inspector .Sep 13 2021, 6:51 PM

Currently on the server side the ImageRecommendationProvider fetches a JSON object from the image recommendation API, that gets included in the HTML, and stored in SuggestedEditSession where AddImageArticleTarget (or maybe the dialog) can access it. That's the same mechanism we used for Add Link. But it only includes the image name and recommendation-related metadata (source wikis etc); not the thumbnail URL or the description. (For Add Link IIRC we extended a VisualEditor component which handled fetching data via extra AJAX requests, so the issue did not come up there.)

There are two approaches to getting the data: do an AJAX request from somewhere in the Add Image JS code, or do it on the server side in ImageRecommendationProvider. Some thoughts:

  • As long as we only needed the thumbnail URL and description, those are available via cached cross-wiki-available abstraction layers (FileRepo and FormatMetadata::fetchExtendedMetadata()) which provide much better performance. It seems likely though that we'll eventually use more things, and AFAIK the WikibaseMediaInfo data (like captions and depict tags) isn't made available in a similar way and would require web requests to the Commons API.
  • Even for web requests, intra-datacenter requests are much faster than a request from the user's browser (especially if they are on a slow connection).
  • OTOH Javascript parallelizes web requests and PHP does not (or at least there is no precedent of trying to do it within MediaWiki, apart from a few very specific maintenance scripts and RESTBase clients), so depending on when the request is fired it might happen during other slow things like VE setup and might be a freebie performance-wise.
  • Commons (obviously) prefers high-quality, high-resolution images. For such images thumbnailing can be quite slow, even if the thumbnail itself is small. MediaWiki (with the configuration used on Wikimedia wikis) thumbnails on-the-fly, whenever the given image in the given resolution is requested for the first time. We might want to make the thumbnail use a "standard" size which is used elsewhere on the wiki (such as the size used in the image history entries) to increase the chance that it is already thumbnailed, or use a standard size that's a bit larger than the visible size, and let the browser scale it down (and accept the quality hit, as the browser will use a faster and less precise algorithm). This goes for T290540: Add an image: image viewer too. Then again, we didn't care about this for the task card thumbnails and it did not seem to cause any issues. (I do remember having lots of trouble related to this with MediaViewer, though.)

Change 721088 had a related patch set uploaded (by MewOphaswongse; author: MewOphaswongse):

[mediawiki/extensions/GrowthExperiments@master] Add an image: show suggestion-specific content in image inspector

Note: Currently the suggestion reason just shows the projects the image is used in. This will be updated once the parent task is finalized.

Screen Shot 2021-09-16 at 3.19.00 PM.png (1×748 px, 341 KB)

kostajh triaged this task as Medium priority.Tue, Sep 21, 12:38 PM

Change 721088 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Add an image: show suggestion-specific content in image inspector

Change 723028 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/extensions/GrowthExperiments@master] Foward metadata errors in ServiceImageRecommendationProvider

Change 723028 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Foward metadata errors in ServiceImageRecommendationProvider

kostajh added a subscriber: kostajh.

The relevant patches have been reviewed, so moving this into QA.

@mewoph -- I just updated this task with the latest specifications from the final mockups and our deep dive. There have been a few changes.