Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image.extension value #1668

Merged
merged 3 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Controller/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ private function parseParameters(string $paramString): void

private function isSvg(string $filename): bool
{
$pathinfo = pathinfo($filename);
$extension = pathinfo($filename, PATHINFO_EXTENSION);

return array_key_exists('extension', $pathinfo) && $pathinfo['extension'] === 'svg';
return $extension === 'svg';
}

private function isImage(string $filename): bool
Expand Down
5 changes: 5 additions & 0 deletions src/Entity/Field/FileExtrasTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ private function getHost(Request $request)

return $host . ':' . $port;
}

private function getExtension(): string
{
return pathinfo($this->__toString(), PATHINFO_EXTENSION);
}
}
2 changes: 2 additions & 0 deletions src/Entity/Field/FileField.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ private function getFieldBase()
'path' => '',
'fieldname' => '',
'url' => '',
'extension' => '',
];
}

Expand All @@ -50,6 +51,7 @@ public function getValue(): array
// Generate a URL
$value['path'] = $this->getPath();
$value['url'] = $this->getUrl();
$value['extension'] = $this->getExtension();

return $value;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/Field/ImageField.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private function getFieldBase()
'fieldname' => '',
'alt' => '',
'url' => '',
'extension' => '',
];
}

Expand All @@ -58,6 +59,7 @@ public function getValue(): array
// Generate a URL
$value['path'] = $this->getPath();
$value['url'] = $this->getUrl();
$value['extension'] = $this->getExtension();

$thumbPackage = new PathPackage('/thumbs/', new EmptyVersionStrategy());
$thumbnailHelper = new ThumbnailHelper();
Expand Down
15 changes: 10 additions & 5 deletions tests/api/get_content.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Feature: Get content with API
"media": @string@,
"url": @string@,
"thumbnail": @string@,
"fieldname": @string@
"fieldname": @string@,
"extension": @string@
},
"@*@": "@*@"
},
Expand Down Expand Up @@ -74,7 +75,8 @@ Feature: Get content with API
"media": @string@,
"url": @string@,
"thumbnail": @string@,
"fieldname": @string@
"fieldname": @string@,
"extension": @string@
},
"@*@": "@*@"
},
Expand Down Expand Up @@ -125,7 +127,8 @@ Feature: Get content with API
"media": @string@,
"url": @string@,
"thumbnail": @string@,
"fieldname": @string@
"fieldname": @string@,
"extension": @string@
},
"@*@": "@*@"
},
Expand Down Expand Up @@ -189,7 +192,8 @@ Feature: Get content with API
"media": @string@,
"url": @string@,
"thumbnail": @string@,
"fieldname": @string@
"fieldname": @string@,
"extension": @string@
},
"@*@": "@*@"
},
Expand Down Expand Up @@ -250,7 +254,8 @@ Feature: Get content with API
"media": @string@,
"url": @string@,
"thumbnail": @string@,
"fieldname": @string@
"fieldname": @string@,
"extension": @string@
},
"@*@": "@*@"
},
Expand Down