Page MenuHomePhabricator

mobile-html: enhance media-list to include exact image URLs
Closed, ResolvedPublic

Description

Background information

media-list doesn't include the exact image URLs that will be requested by mobile-html, only the original file name. This makes it difficult to save a page for offline without knowing the internal implementation details of mobile-html and how to construct the thumbnail URL at the correct size.

What

Add the exact image URLs to media-list

How

Pull the src and srcset from all image tags.

I'd imagine a structure along the lines of:

[ // list of all images
  { 
    srcset: [
      {src: //upload.wikimedia.org/wikipedia/commons/thumb/6/69/Dog_morphological_variation.png/640px-Dog_morphological_variation.png, scale: 1x}, // import src as 1x if 1x isn't in srcset
      {src: //upload.wikimedia.org/wikipedia/commons/thumb/6/69/Dog_morphological_variation.png/640px-Dog_morphological_variation.png, scale: 1.5x}
    ]
  },
  {
    srcset: [
      {src: //upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Dog_anatomy_lateral_skeleton_view.jpg/640px-Dog_anatomy_lateral_skeleton_view.jpg, scale: 1x},
      {src: //upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Dog_anatomy_lateral_skeleton_view.jpg/960px-Dog_anatomy_lateral_skeleton_view.jpg, scale: 1.5x},
      {src: //upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Dog_anatomy_lateral_skeleton_view.jpg/1280px-Dog_anatomy_lateral_skeleton_view.jpg, scale: 2x}   
    ]
  }
]

Event Timeline

JoeWalsh triaged this task as High priority.Aug 7 2019, 7:59 PM
JoeWalsh lowered the priority of this task from High to Medium.
JoeWalsh updated the task description. (Show Details)
JoeWalsh updated the task description. (Show Details)

Could it be instead a new property in the media-list item? For example:

items: [
    {
        title: "File:Dog_morphological_variation.png",
        section_id: 0,
        type: "image",
        caption: {
            html: "",
            text: ""
        },
        showInGallery: true
        srcset: [
            {src: //upload.wikimedia.org/wikipedia/commons/thumb/6/69/Dog_morphological_variation.png/640px-Dog_morphological_variation.png, scale: 1x}, // import src as 1x if 1x isn't in srcset
            {src: //upload.wikimedia.org/wikipedia/commons/thumb/6/69/Dog_morphological_variation.png/640px-Dog_morphological_variation.png, scale: 1.5x}
        ]
    }
]

@MSantos yes that would be fine as well as long as the srcset is identical to what is output by mobile-html - I'm not sure if the srcset on the parsoid output is identical to what's on the mobile-html output

@MSantos It looks like the srcset differs. Would you make media-list be based off of mobile-html instead of parsoid html?

mobile-html:

<span class="pagelib_theme_image_presumes_white_background pagelib_lazy_load_placeholder pagelib_lazy_load_placeholder_pending" style="width: 640px;" data-class="pagelib_theme_image_presumes_white_background" data-src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Collage_of_Nine_Dogs.jpg/640px-Collage_of_Nine_Dogs.jpg" data-srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Collage_of_Nine_Dogs.jpg/1280px-Collage_of_Nine_Dogs.jpg 2x, //upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Collage_of_Nine_Dogs.jpg/960px-Collage_of_Nine_Dogs.jpg 1.5x" data-width="640" data-height="561" data-data-file-width="1665" data-data-file-height="1463"><span style="padding-top: 87.65625%;"></span></span>

vs parsoid:

<img resource="./File:Collage_of_Nine_Dogs.jpg" src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Collage_of_Nine_Dogs.jpg/260px-Collage_of_Nine_Dogs.jpg" data-file-width="1665" data-file-height="1463" data-file-type="bitmap" height="228" width="260" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Collage_of_Nine_Dogs.jpg/520px-Collage_of_Nine_Dogs.jpg 2x, //upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Collage_of_Nine_Dogs.jpg/390px-Collage_of_Nine_Dogs.jpg 1.5x">

@MSantos It looks like the srcset differs. Would you make media-list be based off of mobile-html instead of parsoid html?

I'm thinking about applying the adjustThumbWidth transformation to the parsoid output and get the srcset provided by mobile-html

JoeWalsh renamed this task from mobile-html: enhance mobile-html-offline-resources to include exact image URLs to mobile-html: enhance media-list to include exact image URLs.Aug 8 2019, 7:10 PM
JoeWalsh updated the task description. (Show Details)

Change 529172 had a related patch set uploaded (by MSantos; owner: MSantos):
[mediawiki/services/mobileapps@master] media-list: add srcset of scaled thumbnails

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

Change 529172 merged by jenkins-bot:
[mediawiki/services/mobileapps@master] media-list: add srcset of scaled thumbnails

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

Mentioned in SAL (#wikimedia-operations) [2019-08-15T17:41:28Z] <mbsantos@deploy1001> Started deploy [mobileapps/deploy@1bd2bea]: Update service-mobileapp-node to 5c1da03 (T230067 T229984)

Mentioned in SAL (#wikimedia-operations) [2019-08-15T17:47:21Z] <mbsantos@deploy1001> Finished deploy [mobileapps/deploy@1bd2bea]: Update service-mobileapp-node to 5c1da03 (T230067 T229984) (duration: 05m 53s)

Change 532719 had a related patch set uploaded (by MSantos; owner: MSantos):
[mediawiki/services/mobileapps@master] media-list: pull src property from image tag

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

Change 532719 merged by jenkins-bot:
[mediawiki/services/mobileapps@master] media-list: pull src property from image tag

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

DannyS712 subscribed.

[batch] remove patch for review tag from resolved tasks