Page MenuHomePhabricator

Community updates: use optimised image sizes
Closed, ResolvedPublic

Description

Within the parent task the CommonsFileControl was introduced to allow to select image files from commons. When a file is selected, its source file url is stored as URL string in the config. The source file is commonly not optimised for small size and different density screens.

This task is to solve that and use optimised images in desktop and mobile for the Community updates banner. Also there are no size constraints in terms of selecting the image so it could look pretty bad for landscape and portrait proportions. See:

Screenshot 2024-08-01 at 17.55.03.png (448×678 px, 60 KB)

Alternatives for showing optimized images

  1. Request thumbnail url in the API request of the component and store two urls, eg: 1.5x and 2x
  2. Store just the file title and retrieve the approrpiate image urls when rendering the module in the server (would probably require caching)
  3. Store just the file title and try to generate the thumbnail URLs in the client
    1. By doing string concatenation of the known parts
    2. By doing a request to the API

Acceptance criteria

  • Each platform (mobile, desktop) gets an optimized version of the image
  • Some image size/proportion is enforced, tbd

Event Timeline

Design feedback requested: feedback on image size requirements & Is a boarder needed.

In 1:1 conversation with @Urbanecm_WMF it has been brought that storing one or two URLs might not be a good idea some reasons. Among them the unclear use-case for the consumer, eg: a consumer could be interested in using the image in wikitext, eg: [[File:SomeFile...]]. Also the URL could change over time. We're thinking that the appropriate approach here would be to only store the filename, which in MW coincides with the page title.

This has brought again the duplicity with having a PageTitle control and another control only for Commons files. Since re-using the controls with some configuration is not possible until we resolve T367494: Community configuration: Add support for parametrised controls and T370534: Decision on how UI schema abstraction should work, enforcing custom validation for this control could be problematic in the future when we want to generalize it.

Since enforcing resolution requirements might be tricky, we could just add some description or help text that makes the user aware that the image will be presented in 1:1 ratio. Then we can force whatever image we get into the thumbnail area with some of CSS properties cover or contain to keep its aspect ratio.

As per the data model the CommonsControl should use, if we're only using the page title, then refactoring CommonsFile definition may be good too, see source

Change #1062097 had a related patch set uploaded (by Cyndywikime; author: Cyndywikime):

[mediawiki/extensions/CommunityConfiguration@master] [WIP]:CommunityUpdates: Optimize image handling for Community Updates

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

Change #1062390 had a related patch set uploaded (by Cyndywikime; author: Cyndywikime):

[mediawiki/extensions/GrowthExperiments@master] [WIP]CommunityUpdates: Generate thumbnail URL

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

Change #1062390 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] CommunityUpdates: Use optimized image sizes for thumbnails

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

Etonkovidova subscribed.

There are still some deficiencies in how images of different sizes and file types are displayed.

Summary of the issues
(1) From https://phabricator.wikimedia.org/T365885#10081088

  • thumbnail images are not always 74x74
Screen Shot 2024-08-20 at 2.39.11 PM.png (630×1 px, 94 KB)
Screen Shot 2024-08-20 at 4.41.35 PM.png (1×1 px, 520 KB)
  • landscape-oriented images are not aligned with the title
  • the placeholder image is displayed 40x40

Screen Shot 2024-08-20 at 5.14.53 PM.png (710×1 px, 91 KB)

<span class="cdx-thumbnail__placeholder"><span class="cdx-thumbnail__placeholder__icon"></span></span>


@media (min-width: 640px) {
    .cdx-card-content-row-1 .cdx-card__thumbnail {
        width: 74px;
        height: 74px;
    }
}

(2) T373215: Community Updates module-Image field - different file formats are accepted

Change #1062097 abandoned by Cyndywikime:

[mediawiki/extensions/CommunityConfiguration@master] MediaWikiDefinitions: change CommonsFile type to string and drop URL

Reason:

Not needed

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