|
While adding alt-text, I ran into an API/compatibility issue. I’d like to let users set alt text at insertion time via:
These are public APIs. Internally they call:
However, the existing API and tests assume a 3-arg positional call chain: document.add_picture(path, width, height)
run.add_picture(path, width, height)
part.new_pic_inline(image, width, height)
If we extend this with positional title / descr, we either:
I think there are three options:
@scanny Which option would you prefer? |
Sorry, something went wrong.
Builds on #227 and #317.
Summary
This PR introduces first-class support for Word Alt Text in python-docx. Users can now set and read both the Alt Text Title and Alt Text Description (as shown in Word’s Accessibility pane) directly through the API when inserting or editing pictures.
Motive
Previously, python-docx did not expose a clean API for working with image alternative text. Users had to manually manipulate XML to set or retrieve <wp:docPr> attributes (title, descr). This enhancement improves accessibility workflows and enables automated tools (e.g., alt-text generators) to embed compliant descriptions directly into Word documents.
Implementation
Usage Examples
Additional Notes