Hello,
By default DOCXPath and DOCXCustomizer methods select elements that are direct children of the root tag, w:body for the document content.
On https://www.phpdocx.com/documentation/introduction/docxpath and the API pages you can read this same information:
parent (string, main document body as default, allows to set any parent or a specific one)
Main document body as default, allows to set any parent or a specific one. w:body (default), '/' (any parent) or any other specific parent (/w:tbl/, /w:tc/, /w:r/...).
As you are adding the image in a table, you need to query the elements in all parents:
$docx = new CreateDocx();
$html = '<table width="100%"><tr><td><img src="image.png" width="90" height="90"></td></tr></table>';
$docx->embedHTML($html, ['useHTMLExtended' => true]);
$docx->customizeWordContent(['type' => 'image', 'parent' => '/'], ['imageAlign' => 'center']);
$docx->createDocx('output');
Also note that you can add a center align image in a table with embedHTML without using DOCXCustomizer:
$html = '<table width="100%"><tr><td><p style="text-align: center;"><img src="image.png" width="90" height="90"></p></td></tr></table>';
$docx->embedHTML($html);
DOCXCustomizer allows changing styles on-the-fly, but if you are adding new contents the easiest approach is applying the styles to the contents. On the following pages you can find all options and stylesavailable for each method and tag:
- API : https://www.phpdocx.com/documentation/api-documentation
- HTML API : https://www.phpdocx.com/documentation/htmlapi-documentation
Regards.