PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.26k stars 2.69k forks source link

HTML image link image not displayed #1589

Open charmoller opened 5 years ago

charmoller commented 5 years ago

This is:

Expected Behavior

When converting HTML using Html::addHtml() image links (image nested instead an anchor tag) the resulting Word document should display the image with a link to it.

Current Behavior

When converting HTML using Html::addHtml() image links (image nested instead an anchor tag) aren't working correctly. The resulting Word document is not displaying the image at all.

How to Reproduce

Please provide a code sample that reproduces the issue.

<p><a href="file_link.html"><img src="my-image.jpg" alt="My Image" width="99" height="75" /></p>

Context

GewoonRoy commented 5 years ago

I got the same issue. Perhaps the information below is useful for a solution.

Additional information: The image get skipped while parsing the nodes. (File: PHPWord/Shared/Html.php).

The p is parsed and while parsing it updated the $element to an instance of the AbstractContainer. After the a element is being parsed it notice in the parseChildNodes() that $element is an instance of AbstractContainer. The image is skipped which results in an empty file because no value is available within the p nor a element.

Hope it helps.

deblaci commented 5 years ago

Is there any workaround for this?

jayanorangehrmlive commented 3 years ago

I have the same issue could you resolve it