Skip to content

Pre-proposal: standardize setting alt text from alt metadata in display_data #120

@minrk

Description

@minrk

Problem:

alt text is required for image accessibility, but there's currently no documented way to set alt text on displayed images.

Proposal:

populate alt attribute from the alt metadata field in display_data messages, if defined. Alternative: use a non-standard but more specific name, such as html-alt, or alt-text.

There are a few places this info can come from, such as ImageDescription EXIF data, but we should have a protocol-level place for users and libraries to be able to easily populate these fields.

Another alternative comes from the fact that the Jupyter protocol mime-bundles already are multiple representations of the same object, and should always include plain text. So another valid choice is for User Interfaces (JupyterLab) to populate the alt text for images with the text/plain representation of the same output. However, in practice that is very rarely a good choice for alt text for an image, since it describes the displayed object, not the image itself. I'd need to hear from accessibility folks if that's better or worse than no alt text at all. But maybe this should lead us to make better text representations in text/plain, too!

While using the text/plain output may be a reasonable default when alt is unspecified, I still think it makes sense to pass through the alt metadata so that users and libraries can more easily set alt on the destination element, regardless of what we choose for possible sources of default values in the HTML.

Still to iron out:

  • example or API for how to get alt text for e.g. matplotlib figures. Computing alt text for figures is tricky, and not likely to be a property of the Figure object itself, so we should show an example of what it might look like, e.g. with the work here

Affected packages:

  • image publishers (ipykernel, other kernels)
  • notebook renderers (JupyterLab, nbconvert)

references:

Suggested reviewers:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions