From 9281a8786f9ac4e44dd62cedad77eafce9111a7b Mon Sep 17 00:00:00 2001 From: retroluxfilm Date: Fri, 23 Feb 2024 18:54:45 +0100 Subject: [PATCH] Fixed that mods that are created with OMM 1.2.x will show their image in the remote repository --- src/Package/Package.php | 21 ++++++++++++++++----- src/Package/PackageXML.php | 11 +++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/Package/Package.php b/src/Package/Package.php index 0cfdaf9..67d9ebd 100644 --- a/src/Package/Package.php +++ b/src/Package/Package.php @@ -45,6 +45,7 @@ class Package protected string $packageArchiveFile; protected string $packageArchiveFilePath; protected string $logoImageData; + protected string $thumbnailData; protected int $packageByteSize; protected string $customURL; @@ -115,12 +116,19 @@ public function createRemotePackageDescriptor(): RemotePackageDescriptor } // add logo image if set - if (isset($this->logoImageData)) { - - // Crop & Resize logo to max 128x128 pixels in size - $thumbnail = PackageHelper::createThumbnail($this->logoImageData); + if (isset($this->logoImageData) || isset($this->thumbnailData)) { + + if(isset($this->thumbnailData)) { + // directly pass image data that was already encoded internally in OMM + $thumbnail = $this->thumbnailData; + } else { + // Crop & Resize logo to max 128x128 pixels in size + // NOTE: This is for legacy mods created before OMM 1.2.x + $thumbnail = PackageHelper::createThumbnail($this->logoImageData); + $thumbnail = PackageHelper::encodePackageLogo($thumbnail); + } - $picture = $xml->createElement(RemotePackageDescriptor::TAG_MOD_PICTURE, PackageHelper::encodePackageLogo($thumbnail)); + $picture = $xml->createElement(RemotePackageDescriptor::TAG_MOD_PICTURE, $thumbnail); $remote->appendChild($picture); } @@ -195,6 +203,9 @@ protected function retrieveInformationFromArchive(string $packageArchiveFilePath } } + // load data from thumbnail tag + $this->thumbnailData = $this->packageXML->getThumbnailData(); + // closes package zip after reading out all required information $packageZip->close(); } diff --git a/src/Package/PackageXML.php b/src/Package/PackageXML.php index efc8361..c664365 100644 --- a/src/Package/PackageXML.php +++ b/src/Package/PackageXML.php @@ -93,6 +93,17 @@ public function getLogoImage(): string return (string)$this->xml->picture; } + /** + * Get package logo + * @return string + */ + public function getThumbnailData(): string + { + //return thumbnail data from the package + return (string) $this->xml->thumbnail; + } + + /** * Get category of the package * @return string