Forum


Replies: 7   Views: 2031
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 admin  · 03-06-2020 - 06:43

Hello,

Indexer doesn't extract alt text contents. You can use getDocxPathQueryInfo with a custom Xpath query to get that information:

$referenceNode = array(
    'customQuery' => '//w:drawing//wp:docPr',
);

$contents = $docx->getDocxPathQueryInfo($referenceNode);

foreach ($contents['elements'] as $content) {
    echo $content->getAttribute('descr');
}

Regards.