Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ All notable changes to this project will be documented in this file.
- Added relations checksum feature flag.
- Fixes saving issues described in issue where saving resulted in infinite spinner.
- Fixed loading of routes containing null string values.
- Fixed thumbnail resolve issue.
- Fixed relations checksum test.
- Optimized release data fetching.
- Optimized list loading.
Expand Down
11 changes: 10 additions & 1 deletion src/State/MediaProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use App\Repository\SlideRepository;
use App\Utils\ValidationUtils;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Liip\ImagineBundle\Imagine\Data\DataManager;
use Liip\ImagineBundle\Imagine\Filter\FilterManager;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Uid\Ulid;
Expand All @@ -43,6 +45,8 @@ public function __construct(
private readonly RequestStack $requestStack,
private readonly StorageInterface $storage,
private readonly CacheManager $imagineCacheManager,
private readonly DataManager $dataManager,
private readonly FilterManager $filterManager,
private readonly iterable $itemExtensions,
ProviderInterface $collectionProvider,
MediaRepository $entityRepository,
Expand Down Expand Up @@ -164,7 +168,12 @@ public function toOutput(object $object): MediaDTO
}

if (str_starts_with($object->getMimeType(), 'image/')) {
$output->thumbnail = $this->imagineCacheManager->getBrowserPath($path, 'thumbnail');
if (!$this->imagineCacheManager->isStored($path, 'thumbnail')) {
$binary = $this->dataManager->find('thumbnail', $path);
$filteredBinary = $this->filterManager->applyFilter($binary, 'thumbnail');
$this->imagineCacheManager->store($filteredBinary, $path, 'thumbnail');
}
$output->thumbnail = $this->imagineCacheManager->resolve($path, 'thumbnail');
} elseif (str_starts_with($object->getMimeType(), 'video/')) {
$output->thumbnail = $baseUrl.'/media/thumbnail_video.png';
} else {
Expand Down
15 changes: 15 additions & 0 deletions tests/Api/MediaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ public function testGetItem(): void
// $this->assertMatchesResourceItemJsonSchema(Media::class);
}

public function testThumbnailUrlDoesNotContainResolve(): void
{
$client = $this->getAuthenticatedClient();
$iri = $this->findIriBy(Tenant\Media::class, ['tenant' => $this->tenant]);

$response = $client->request('GET', $iri, ['headers' => ['Content-Type' => 'application/ld+json']]);

$this->assertResponseIsSuccessful();
$responseArray = $response->toArray();

$this->assertArrayHasKey('thumbnail', $responseArray);
$this->assertStringContainsString('/media/cache/thumbnail/', $responseArray['thumbnail']);
$this->assertStringNotContainsString('/media/cache/resolve/', $responseArray['thumbnail']);
}

public function testMediaUrlFromForeignTenant(): void
{
$iri = $this->findIriBy(Tenant\Media::class, ['title' => 'media_def_shared_to_abc']);
Expand Down
Loading