Page MenuHomePhabricator

Ensure alt text is always inserted before the image caption.
Closed, DeclinedPublic

Description

During experiment development, there are some cases where we had to tack on alt text at the very end. In these particular situations, the caption text was more complicated (containing templates and links). We strip these items out of the caption for display on the review screen, but that made it impossible to seek out later in the flow when publishing.

For this task we should extract two different captions from the image wikitext: One for display to show on the review screen, and another (without stripping) for seeking. This "seeking" caption can then be easily found in the image wikitext, where we can insert the alt text in front of it.

Event Timeline

Brooke will update the Javascript to pass the information on what is the caption

bvibber subscribed.

Going to tweak the JS side to correctly return the parameter position data so we can replace it in the right location...

@bvibber FYI I moved your library and adjusted it a bit since you last took a look. It now lives within our WMFData package, and it accessible via this WMFWikitextUtils file.

I modified the JS-side a bit to allow passing in targetNamespaces and targetAltParams from Swift, so that it's internationalized.

I quickly slapped together this extractCaptionForDisplay extension method for MissingAltTextLink - I'm calling it after the MissingAltTextLinks are determined before entering the alt text input flow. There may be a cleaner way to do this so I'm happy to scrap it entirely. Basically I just need the caption from your library, or indicators of where the caption starts and how long it is. I can clean it up further in Swift if I need to remove templates, etc. before displaying in the UI. And then later I can use your caption start index for inserting the alt text.

I don't think this is needed for the experiment (which we're hoping to wrap up development this week on), but that could change if QA determines my workaround isn't working well enough.

HNordeenWMF lowered the priority of this task from Medium to Low.Sep 27 2024, 3:26 PM

Moving to the backlog, we would pick this up if needed for the permanent versoin.