added functionality for reading alt text of shape
#508 issue implemented in this PR. kindly review it.
I have implemented this property on my local system and on my fork copy. It works as it should.
@honcharovs are you asking me or the repo owner?
Hi All. Aware this is an old thread. Is there anything preventing this being merged? It would be a really useful addition.
Hi All. Just want to upvote this. @scanny, please review and include.
Hi, it would be useful capability. @scanny could you include it?
This would be super useful. Any obstacles to it being merged?
@hermanc1 You can accomplish this inline like this:
alt_text = shape._element._nvXxPr.cNvPr.attrib.get("descr", "")
or wrap it in a utility/work-around function like this:
from pptx.shapes.base import BaseShape
def shape_alt_text(shape: BaseShape) -> str:
"""Alt-text defined in shape's `descr` attribute, or "" if not present."""
return shape._element._nvXxPr.cNvPr.attrib.get("descr", "")
We might well add this at something like shape.alt_text, but it's not currently on the docket and a function like this is easy to add to your package or in some sort of pptxutils package you put together if you use it on a lot of projects and want to maintain only one copy of the functions like this.
Thank you @scanny - I appreciate it! I implemented it now and it works well. One small note: in the docstring for the function, you call the attribute desc, but (as in your code) it is descr.
Thank you once again - it really helps!
Good catch, thanks @hermanc1 :) I've updated the docstring.
I expect to be in making a few additions before long so have shortlisted this to consider for the next release as well.
is there any update?
Any progress here?