Forum


Replies: 2   Views: 1640
Replaceplaceholderimage not insert image
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  · 07-07-2020 - 15:08

Hello,

Using replacePlaceholderImage, the placeholder needs to be added to the alternative text of the image using MS Word or any other DOCX editor. On https://www.phpdocx.com/api-documentation/templates/replace-placeholder-image-Word-document you can read more information and sampes about using this metod.

If you need to replace a text placeholder by an image, you need to use a WordFragment and replaceVariableByWordFragment:

$image = new WordFragment($docx, 'document');
$image->addImage(array('src' => 'image.png' , 'scaling' => 50, 'float' => 'right', 'textWrap' => 1));

$docx->replaceVariableByWordFragment(array('PLACEHOLDER' => $image ), array('type' => 'block'));

You can read more information about both methods on the following pages of the practical guide:

Regards.