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 extension placeholder for serialized medias #127
Add extension placeholder for serialized medias #127
Conversation
@alexander-schranz @wachterjohannes to prevent the BC break, we could maybe add a config like this: sulu_headless:
media:
use_preferred_extension: true WDYT? |
@@ -94,15 +94,19 @@ public function serialize(MediaInterface $media, string $locale, ?SerializationC | |||
$preferredExtension = $this->imageConverter->getSupportedOutputImageFormats($formatMediaApi->getMimeType())[0] ?? null; | |||
if ($preferredExtension) { | |||
$fileName = \pathinfo($fileName)['filename'] . '.' . $preferredExtension; | |||
$mediaData['preferredExtension'] = $preferredExtension; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$mediaData['preferredExtension'] = $preferredExtension; | |
$mediaData['formatPreferredExtension'] = $preferredExtension; |
So they are beside each other in the json response.
@@ -94,15 +94,19 @@ public function serialize(MediaInterface $media, string $locale, ?SerializationC | |||
$preferredExtension = $this->imageConverter->getSupportedOutputImageFormats($formatMediaApi->getMimeType())[0] ?? null; | |||
if ($preferredExtension) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think formatUri
, formatPreferredExtension
should be null
if there is no preferredExtension as I think that indicates that there are no formats available for this media. E.g. .doc
, .xls
, ...
@@ -80,6 +80,7 @@ | |||
"version": 1, | |||
"subVersion": 0, | |||
"name": "test-image.png", | |||
"preferredExtension": "png", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would replace @string@
in formatUri
to check the Uri is as expected.
$this->formatCache->getMediaUrl(1, 'media-1.extension', '{format}', 1, 0) | ||
->willReturn('/media/1/{format}/media-1.extension?v=1-0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create a real instance of LocalFormatCache
so we avoid this mock.
@Prokyonn if somebody is using |
UPGRADE.md
Outdated
"formatUri": "/media/1/{format}/media-1.{extension}?v=1-0", | ||
"preferredExtension": "png" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"formatUri": "/media/1/{format}/media-1.{extension}?v=1-0", | |
"preferredExtension": "png" | |
"formatUri": "/media/1/{format}/media-1.{extension}?v=1-0", | |
"formatPreferredExtension": "png" |
@Prokyonn would also go with a flag and throw a deprecation message when it is not set! else the PR LGTM. |
as discussed internally, we'll omit the configuration BC layer, because of
|
No description provided.