diff --git a/docs/changes/1.2.0.md b/docs/changes/1.2.0.md index 4247f38b8..3be80952c 100644 --- a/docs/changes/1.2.0.md +++ b/docs/changes/1.2.0.md @@ -30,6 +30,7 @@ - ODPresentation Reader : Read differents units for margin by [@Progi1984](https://github.com/Progi1984) fixing [#830](https://github.com/PHPOffice/PHPPresentation/pull/830) in [#847](https://github.com/PHPOffice/PHPPresentation/pull/847) - PowerPoint2007 Reader : Fixed loading of fonts by [@ag3202](https://github.com/ag3202) and [@Progi1984](https://github.com/Progi1984) in [#851](https://github.com/PHPOffice/PHPPresentation/pull/851) - PhpOffice\PhpPresentation\Style\TextStyle : Fixed typo for default indent by [@Progi1984](https://github.com/Progi1984) in [#857](https://github.com/PHPOffice/PHPPresentation/pull/857) +- Fixed adding custom SVGs by [@seanlynchwv](http://github.com/seanlynchwv) in [#881](https://github.com/PHPOffice/PHPPresentation/pull/881) ## Miscellaneous - CI: Added ODFValidator by [@Progi1984](https://github.com/Progi1984) fixing [#678](https://github.com/PHPOffice/PHPWord/issues/678) in [#653](https://github.com/PHPOffice/PHPWord/pull/653) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/ContentTypes.php b/src/PhpPresentation/Writer/PowerPoint2007/ContentTypes.php index 87e4d5b57..0a89c37cc 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/ContentTypes.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/ContentTypes.php @@ -49,8 +49,7 @@ public function render(): ZipInterface // XML $this->writeDefaultContentType($objWriter, 'xml', 'application/xml'); - // SVG - $this->writeDefaultContentType($objWriter, 'svg', 'image/svg+xml'); + // SVG will pre-register in $aMediaContentTypes // Presentation $this->writeOverrideContentType($objWriter, '/ppt/presentation.xml', 'application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml'); @@ -106,11 +105,12 @@ public function render(): ZipInterface // Add media content-types $aMediaContentTypes = []; - // GIF, JPEG, PNG + // GIF, JPEG, PNG, SVG $aMediaContentTypes['gif'] = 'image/gif'; $aMediaContentTypes['jpg'] = 'image/jpeg'; $aMediaContentTypes['jpeg'] = 'image/jpeg'; $aMediaContentTypes['png'] = 'image/png'; + $aMediaContentTypes['svg'] = 'image/svg+xml'; foreach ($aMediaContentTypes as $key => $value) { $this->writeDefaultContentType($objWriter, $key, $value); } @@ -133,6 +133,11 @@ public function render(): ZipInterface $extension = strtolower($shapeIndex->getExtension()); $mimeType = $shapeIndex->getMimeType(); + // Normalize any odd returns (some environments report "image/svg") + if ($extension === 'svg') { + $mimeType = 'image/svg+xml'; + } + if (!isset($aMediaContentTypes[$extension])) { $aMediaContentTypes[$extension] = $mimeType;