diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 7efc0f1ac8..9ece5e7f40 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -573,7 +573,6 @@ public function setImageValue($search, $replace, $limit = self::MAXIMUM_REPLACEM $searchParts[$this->getFooterName($headerIndex)] = &$this->tempDocumentFooters[$headerIndex]; } - // define templates // result can be verified via "Open XML SDK 2.5 Productivity Tool" (http://www.microsoft.com/en-us/download/details.aspx?id=30425) $imgTpl = ''; @@ -605,7 +604,12 @@ public function setImageValue($search, $replace, $limit = self::MAXIMUM_REPLACEM $wholeTag = $matches[0]; array_shift($matches); list($openTag, $prefix, , $postfix, $closeTag) = $matches; - $replaceXml = $openTag . $prefix . $closeTag . $xmlImage . $openTag . $postfix . $closeTag; + if (isset($replacesList[0]['align']) and in_array($replacesList[0]['align'], array('left', 'right', 'center'))) { + $position = ''; + } else { + $position = ''; + } + $replaceXml = $openTag . $prefix . $closeTag . $position . $xmlImage . $openTag . $postfix . $closeTag; // replace on each iteration, because in one tag we can have 2+ inline variables => before proceed next variable we need to change $partContent $partContent = $this->setValueForPart($wholeTag, $replaceXml, $partContent, $limit); }