Replies: 2   Views: 1066
Replacetablevariable doesn't render <img> tag
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 therasim  · 23-02-2017 - 17:36

I'm using 6.5 version of PHPDocX, and I have a method that cleans a piece of HTML and then perfoms the following

// As an example: 
for ($i = 0; $i < 20; $i++) {
   $html = '<img src="/var/www/images/image.jpg"><p>This is a test</p>';

   $element = new WordFragment($docx);

   $table['elements][] = [
     'name' => 'Test',
     'description' => element,

// Later in the code
$docx->replaceTableVariable($table['elements'], ['firstMatch' => true]);

When I generate the code I can't see the image. The image has permissions to be read/write. If I switch and try to use addImage() method, PHPDocX complains that the image doesn't exist. Any hints on how to fix this, please?

Thanks in advance,

Posted by admin  · 23-02-2017 - 18:20


When you use embedHtml, images must be available through an URL (absolute or relative) and set the downloadImages option to true. You can't use a local path to add images.

If the addImage method is returning a file not found error, then the image is not accesible through PHP or it doesn't exist. We recommend you to run the included examples to test this method and check read access to the images you are adding.


Posted by therasim  · 24-02-2017 - 03:31

Thank you very much; adding the downloadImages option helped me with this