Forum


Replies: 3   Views: 3174
Embedding external images in html
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 davelavinsky  · 07-05-2018 - 10:30

Why doesn't embedding external images in HTML work ?

$html .= "<img src='http://url.com/image.jpg'/>";
$docx->embedHTML($html);

Using phpdocx-corporate-5.5

Posted by admin  · 07-05-2018 - 11:37

Hello,

We have tested it and the image is added correctly. Maybe you need to set downloadImages as true; we recommend you to read the documentation available on:

https://www.phpdocx.com/documentation/cookbook/insert-images-html

As you are using phpdocx 5.5, the stream mode is not available. This stream mode is only available since phpdocx 7.5 and newer.

Regards.

Posted by davelavinsky  · 07-05-2018 - 11:57

$docx = new CreateDocx();
$text = 'Testing 123';
$docx->addText($text);
$img_src = "https://chart.googleapis.com/chart?chs=250x100&chd=t:60,40&cht=p3&chl=Hello|World";
$html = "<img src='{$img_src}'/>";
$docx->embedHTML($html);
$docx->createDocx('../chart');

I get Read Error.

https://imgur.com/a/H2P5G9H

Posted by admin  · 07-05-2018 - 12:10

Hello,

You are trying to add a not static image (a file) as phpdocx 7 and previous versions of phpdocx need. You need to download the image and then insert it or use the stream mode available in phpdocx 7.5 and newer.

Regards.