Skip to content

Commit

Permalink
Merge pull request #3 from elgentos/add-elgentos-imgproxy
Browse files Browse the repository at this point in the history
Add elgentos imgproxy
  • Loading branch information
IvoElgentos authored Oct 2, 2024
2 parents c8e22cc + e2939a1 commit 7d7a1c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"require": {
"php": "^8.2",
"crocodile2u/imgproxy-php": "^v2.0",
"elgentos/imgproxy-php": "^3.0",
"magento/framework": "^103.0",
"magento/module-catalog-graph-ql": "^100.4",
"magento/module-search": "^101.1",
Expand Down
14 changes: 13 additions & 1 deletion src/Model/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public function getCustomUrl(
if ($customProcessingOptions) {
$options = array_map('trim', explode('/', $customProcessingOptions));
foreach ($options as $option) {
$arguments = explode(':', $option);
$arguments = $this->convertCustomProcessingOptionsToInt(explode(':', $option));

$name = array_shift($arguments);

// @todo We need to use reflection here
Expand All @@ -100,4 +101,15 @@ public function getCustomUrl(

return $imgProxyUrl;
}

private function convertCustomProcessingOptionsToInt(array $arguments): array
{
foreach ($arguments as $key => $value) {
if (is_numeric($value) && ctype_digit($value)) {
$arguments[$key] = (int)$value;
}
}

return $arguments;
}
}

0 comments on commit 7d7a1c0

Please sign in to comment.