From cdd7142d6d7e964ffd1e4258a29eaaa61d40f5e4 Mon Sep 17 00:00:00 2001 From: ag3202 Date: Thu, 29 Feb 2024 13:09:25 +0800 Subject: [PATCH] Addressing Compatibility Issues Causing Crashes --- src/PhpPresentation/Reader/PowerPoint2007.php | 2 ++ .../Slide/Background/Image.php | 23 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/PhpPresentation/Reader/PowerPoint2007.php b/src/PhpPresentation/Reader/PowerPoint2007.php index fb37606d5..54ac92ddc 100644 --- a/src/PhpPresentation/Reader/PowerPoint2007.php +++ b/src/PhpPresentation/Reader/PowerPoint2007.php @@ -485,6 +485,8 @@ protected function loadSlide(string $sPart, string $baseFile): void // Background $oBackground = new Slide\Background\Image(); $oBackground->setPath($tmpBkgImg); + $extension = pathinfo( $pathImage, PATHINFO_EXTENSION ); + $oBackground->setExtension($extension); // Slide Background $oSlide = $this->oPhpPresentation->getActiveSlide(); $oSlide->setBackground($oBackground); diff --git a/src/PhpPresentation/Slide/Background/Image.php b/src/PhpPresentation/Slide/Background/Image.php index d39d00901..a4feef073 100644 --- a/src/PhpPresentation/Slide/Background/Image.php +++ b/src/PhpPresentation/Slide/Background/Image.php @@ -46,6 +46,11 @@ class Image extends AbstractBackground */ protected $width; + /** + * @var string + */ + protected $extension; + /** * Get Path. */ @@ -79,6 +84,19 @@ public function setPath(string $pValue = '', bool $pVerifyFile = true) return $this; } + /** + * Set Extension. + * + * @param string $pValue File Extension + * + * @return self + */ + public function setExtension(string $pValue) + { + $this->extension = $pValue; + return $this; + } + /** * Get Filename. */ @@ -92,9 +110,12 @@ public function getFilename(): string */ public function getExtension(): string { + if($this->extension){ + return $this->extension; + } $exploded = explode('.', $this->getFilename()); - return $exploded[count($exploded) - 1]; + } /**