Forum


Replies: 7   Views: 2263
How to get an image's alt text
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by bkidd  · 04-06-2020 - 14:44

I had a customer upload a template and the picture alt text is stored in the title attribute, not in the descr attribute:

<wp:docPr id="1" name="Picture 1" title="$PHOTO$"/>

I opened the document, cleared the alt text and re-entered the same alt text and, after saving, the alt text was in the descr attribute as I was expecting:

<wp:docPr id="1" name="Picture 1" descr="$PHOTO$"/>

I am assuming this has something to do with the word processor / version of the user and I have asked for more information.

I can also run the query for the title attribute but I am assuming if I need to later replace the image source using replacePlaceholderImage, I'll need the placeholder in the descr attribute so this method can find the correct picture to update.

If this is true, is there any class methods available to insert a descr attrbitue on the element?  I'm hoping I can do this while looping through the results of the query.

UPDATE: User states: I am using Office 2016 on Windows 10 Home. my desktop is a Dell.