Skip to content

Commit

Permalink
Fixed that mods that are created with OMM 1.2.x will show their image…
Browse files Browse the repository at this point in the history
… in the remote repository
  • Loading branch information
retroluxfilm authored and retroluxfilm committed Feb 23, 2024
1 parent aa0e81b commit 9281a87
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/Package/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Package
protected string $packageArchiveFile;
protected string $packageArchiveFilePath;
protected string $logoImageData;
protected string $thumbnailData;
protected int $packageByteSize;
protected string $customURL;

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();
}
Expand Down
11 changes: 11 additions & 0 deletions src/Package/PackageXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9281a87

Please sign in to comment.