Page MenuHomePhabricator

[Spike] Implementation for image insertion inside infobox for en.wiki
Open, MediumPublic

Description

Background:

Within the Add an Image suggested edit task, we suggest images for articles that do not currently have any images. When an article already has an existing infobox, it was a requirement to to insert the image into the infobox instead of into the lead of the article. We ultimately decided to remove this from the scope of the original release, and pick it up after the main flow. The Android version of "Add an image" supports the 5 most popular formats of infoboxes for English Wikipedia (not covering all possible situations), and we want to at least match that behavior. Shay investigated how often this is part of en.wiki edits, and in April, 60% of edits made were into the infobox, 40% into the top of the article.

Shortly after release, we heard feedback that they want images to be inserted into the infobox, highlighting the importance of this behavior.

User stories
  • In articles that have no images and that have an info box, I would like an an option to add the image directly to the image parameter of the info box
  • As a patroller on en.wiki, I don't want to have to continually fix image additions that were not properly added into infoboxes.
Tasks:
  • Spend 1 day implementing the addition of automatic infobox insertion for enwiki, matching Android's behavior (Android accounts for the top 5 most popular template/parameter types)
  • Document progress achieved and what next steps needed to finish the implementation
  • Provide estimate of how many more engineering hours would be needed to finish implementation
Reference

Event Timeline

Not picking up at this time: If we see an abnormal amount of reverts on English, we'll check how many of those reverts were because of the infobox and raise priority of this ticket.

This comment was removed by JTannerWMF.
HNordeenWMF raised the priority of this task from Low to Medium.May 20 2024, 9:27 PM
HNordeenWMF updated the task description. (Show Details)

Ticket updated:

  • An editor request this functionality
  • Data from Shay: in April, 60% of edits made on en.wiki using Android Add an Image were into the infobox, 40% into the top of the article, underscoring the importance of this task. We'll wait until we see the
HNordeenWMF renamed this task from Wikitext: insertion inside infobox for EN Wiki to [Spike] Implementation for image insertion inside infobox for en.wiki.May 21 2024, 7:11 PM
HNordeenWMF updated the task description. (Show Details)
HNordeenWMF updated the task description. (Show Details)

Exact code areas to port on Android: https://github.com/wikimedia/apps-android-wikipedia/blob/main/app/src/main/java/org/wikipedia/edit/insertmedia/InsertMediaViewModel.kt#L198-L318

Can maybe be added as a separate method in WKWikitextUtils.swift, which throws an error if it fails. In ExploreViewController, we try this new method first, then we can fall back to calling insertImageWikitextIntoArticleWikitextAfterTemplates. Add tests in WKWikitextUtilsTests to help with speedier testing.

Notes from the exploration:

  • Implementing like we have on it should be possible - we need some further developemnt and testing, which should not be a huge lift.
  • Based on the Android implementation, I created a new method, attempInsertImageWikitextIntoArticleWikitextInfobox(...), that will handle the logic of inserting the alt text into the top 5 infoboxes on the English wiki.
  • If a valid infobox is found, we attempt to insert the image wikitext after the image name parameter. Otherwise, we insert the parameter name and image wikitext. At this point, my logic is a little off since it's not respecting the spacing between the param and image info, so I'm adding the space manually.

That logic should be repeated to insert alt text and caption parameters, but it should be very similar; just update the parameter name.
I added an aux unit test to help with development, but more tests for all the infobox types and possibilities (adding alt text, not adding alt text, etc etc) should be added.

  • Then, replace the original method with the new one created to decide if infobox insertion should be attempted insertWikitextintoArticle(...). In this method, check for an infobox match from getInfoboxMatch(...) - a function that uses a regex to get a possible match and returns the match range - and if the language is "en," we proceed to try to find the image name parameter.

Thanks @Mazevedo, do you have an estimate of how many more engineering hours would be needed to finish implementation?

We are not currently planning to do the Alt Text experiment on English wiki, but as backup we'd like to have the option to add English. With what you know, how easy would it be to add the additional alt text parameter into the infobox template with correct formatting?