Page MenuHomePhabricator

Populate caption/alt text from SDC
Open, In Progress, Needs TriagePublic

Description

Can the copy text output be populated with data from the file's SDC, including caption or specific properties. Need to investigate how this would be done.

Event Timeline

Dominicbm changed the task status from Open to In Progress.Jan 18 2023, 6:35 PM
Dominicbm moved this task from Backlog to In Progress on the View-it! board.

The View it! API has been updated to support a ?caption=true query parameter. When provided, the API will return captions in all available languages for each image.

This is done by making a call to the Commons action=wbgetentities endpoint and requesting labels. Example:
https://commons.wikimedia.org/w/api.php?action=wbgetentities&sites=commonswiki&titles=File%3ANASA-Apollo8-Dec24-Earthrise.jpg&props=labels

Example when requesting https://view-it.toolforge.org/api/Q2?captions=true:

{
  "total": 5864,
  "results": [
    {
      "image": "https://commons.wikimedia.org/wiki/File:Scandinavia.TMO2003050.jpg",
      "thumb": "https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Scandinavia.TMO2003050.jpg/320px-Scandinavia.TMO2003050.jpg",
      "title": "Scandinavia.TMO2003050.jpg",
      "width": 320,
      "height": 411,
      "captions": {
        "en": {
          "language": "en",
          "value": "Scandinavia from space in winter."
        }
      }
    },
    {
      "image": "https://commons.wikimedia.org/wiki/File:As08-16-2593.jpg",
      "thumb": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/As08-16-2593.jpg/320px-As08-16-2593.jpg",
      "title": "As08-16-2593.jpg",
      "width": 320,
      "height": 283,
      "captions": {
        "pt": {
          "language": "pt",
          "value": "Uma das primeiras imagens tiradas por humanos do planeta terra. Fotografada por a tripulação da Apolo 8 (provavelmente por Bill Anders). A foto mostra a terra a cerca de 30.000 kms de distancia"
        },
        "es": {
          "language": "es",
          "value": "Una de las primeras imagenes del planeta Tierra hecha por los humanos. La foto fue hecha por la tripulación de la Apolo 8 (probablemente por Bill Anders). La foto enseña la tierra a cerca de 30.000 Km de distancia."
        },
        "en": {
          "language": "en",
          "value": "One of the first images taken by humans of the whole Earth. Photographed by the crew of Apollo 8 (probably by Bill Anders) the photo shows the Earth at a distance of about 30,000 km."
        }
      }
    },
...

If no captions are available, captions will just be an empty object {}.

The View it! script has been updated so that the boilerplate thumbnail's caption will be set to the image caption in the user's language. If one isn't available, the thumbnail caption will continue to be Insert caption here. (with localization coming soon).