Skip to content

Commit 5daae39

Browse files
committed
Adding setImageValue
1 parent 75b479f commit 5daae39

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/PhpWord/TemplateProcessor.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,4 +480,25 @@ protected function getSlice($startPosition, $endPosition = 0)
480480

481481
return substr($this->tempDocumentMainPart, $startPosition, ($endPosition - $startPosition));
482482
}
483+
484+
/**
485+
* Set a new image
486+
*
487+
* @param string $search
488+
* @param string $replace
489+
*/
490+
public function setImageValue($search, $replace)
491+
{
492+
// Sanity check
493+
if (!file_exists($replace))
494+
{
495+
return;
496+
}
497+
498+
// Delete current image
499+
$this->zipClass->deleteName('word/media/' . $search);
500+
501+
// Add a new one
502+
$this->zipClass->addFile($replace, 'word/media/' . $search);
503+
}
483504
}

0 commit comments

Comments
 (0)