Skip to content

Commit

Permalink
Force JPG format for image preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Randy Čupić committed Oct 2, 2024
1 parent 0fb92e8 commit e623ba3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions bundle/Resources/config/remote_media.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ image_variations:
transformations:
- { name: limit, params: [600] }
- { name: quality, params: ['auto', 'eco'] }
preview_image:
transformations:
- { name: limit, params: [ 600 ] }
- { name: quality, params: [ 'auto', 'eco' ] }
- { name: format, params: [ 'jpg' ] }
preview_protected:
transformations:
- { name: limit, params: [600] }
- { name: quality, params: ['auto', 'eco'] }
- { name: effect, params: ['pixelate', 5] }
preview_protected_image:
transformations:
- { name: limit, params: [ 600 ] }
- { name: quality, params: [ 'auto', 'eco' ] }
- { name: effect, params: [ 'pixelate', 5 ] }
7 changes: 6 additions & 1 deletion bundle/Templating/Twig/Runtime/RemoteMediaIbexaRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Netgen\RemoteMedia\API\ProviderInterface;
use Netgen\RemoteMedia\API\Values\AuthToken;
use Netgen\RemoteMedia\API\Values\RemoteResource;
use Netgen\RemoteMedia\API\Values\RemoteResourceLocation;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

Expand All @@ -24,10 +25,14 @@ public function getIbexaAdminPreviewHtmlTag(RemoteResourceLocation $remoteResour
? $remoteResourceLocation
: $this->remoteMediaProvider->authenticateRemoteResourceLocation($remoteResourceLocation, AuthToken::fromDuration(600));

$isImage = $remoteResourceLocation->getRemoteResource()->getType() === RemoteResource::TYPE_IMAGE;
$variationName = $canRead ? 'preview' : 'preview_protected';
$variationName = $isImage ? $variationName . '_image' : $variationName;

return $this->remoteMediaProvider->generateVariationHtmlTag(
location: $remoteResourceLocation,
variationGroup: 'ibexa_admin',
variationName: $canRead ? 'preview' : 'preview_protected',
variationName: $variationName,
forceVideo: true,
useThumbnail: !$canRead,
);
Expand Down

0 comments on commit e623ba3

Please sign in to comment.