From f7242e12501829d26574bd10b2649fde0dbfd013 Mon Sep 17 00:00:00 2001 From: Johannes Sochor Date: Wed, 11 Nov 2020 17:18:52 +0100 Subject: [PATCH 1/2] fix image limit --- src/PhpWord/TemplateProcessor.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 7efc0f1ac8..5973dd88b6 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -577,6 +577,7 @@ public function setImageValue($search, $replace, $limit = self::MAXIMUM_REPLACEM // result can be verified via "Open XML SDK 2.5 Productivity Tool" (http://www.microsoft.com/en-us/download/details.aspx?id=30425) $imgTpl = ''; + $i = 0; foreach ($searchParts as $partFileName => &$partContent) { $partVariables = $this->getVariablesForPart($partContent); @@ -609,6 +610,10 @@ public function setImageValue($search, $replace, $limit = self::MAXIMUM_REPLACEM // 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); } + $i++; + if($i >= $limit) { + break; + } } } } From 26e479422abda292e255e98aef41b93a900362d9 Mon Sep 17 00:00:00 2001 From: troosan Date: Sun, 7 Feb 2021 15:06:01 +0100 Subject: [PATCH 2/2] Fix formatting --- src/PhpWord/TemplateProcessor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 5973dd88b6..534f8d6071 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -610,8 +610,8 @@ public function setImageValue($search, $replace, $limit = self::MAXIMUM_REPLACEM // 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); } - $i++; - if($i >= $limit) { + + if (++$i >= $limit) { break; } }