Skip to content

Commit

Permalink
Fix translatable asset controller: make sure the locale is properly p…
Browse files Browse the repository at this point in the history
…assed
  • Loading branch information
sten committed Nov 18, 2024
1 parent 0fd9d86 commit 19367cd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Http/Controllers/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ private function getAssetMedia(HasMedia $asset, ?string $locale = null): ?Media
$assetMedia = null;
if (! $locale && FilamentFlexibleBlocksAssetManagerConfig::hasTranslatableAssets()) {
$locale = app()->getLocale();
$filters = ['locale' => $locale];
$assetMedia = $asset->getFirstMedia($asset->getAssetCollection(), $filters);
}

//first try with locale
$filters = ['locale' => $locale];
$assetMedia = $asset->getFirstMedia($asset->getAssetCollection(), $filters);

if (! $assetMedia) {
//if no media with locale try fallback:
$assetMedia = $asset->getFirstMedia($asset->getAssetCollection());
}

Expand Down

0 comments on commit 19367cd

Please sign in to comment.