Skip to content

Commit cabdb98

Browse files
committed
Remove cdn provider config key
1 parent b160b42 commit cabdb98

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

config/ozu-client.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,5 @@
1818
'api_host' => env('OZU_API_HOST', 'https://ozu.code16.fr/'),
1919
'api_version' => env('OZU_API_VERSION', 'v1'),
2020

21-
'cdn' => [
22-
'provider' => env('OZU_CDN_PROVIDER'),
23-
'url' => env('OZU_CDN_URL'),
24-
],
21+
'cdn_url' => env('OZU_CDN_URL'),
2522
];

src/OzuServiceProvider.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@ public function register()
4848
$this->app->bind(Paginator::class, StaticPaginator::class);
4949
$this->app->bind(LengthAwarePaginator::class, StaticLengthAwarePaginator::class);
5050
$this->app->bind(Thumbnail::class, function ($app) {
51-
if (!$app->environment('production') || !config('ozu-client.cdn.url')) {
51+
if (!$app->environment('production') || !config('ozu-client.cdn_url')) {
5252
return $app->make(LocalThumbnail::class);
5353
}
5454

55-
return match(config('ozu-client.cdn.provider')) {
56-
'imagekit' => $app->make(ImageKitThumbnail::class),
57-
'keycdn' => $app->make(KeyCdnThumbnail::class),
58-
default => $app->make(LocalThumbnail::class)
59-
};
55+
// Have to rely on the URL to determine the CDN provider for now,
56+
// because we are limited to 10 params for the deployment script :/
57+
if (str(config('ozu-client.cdn_url'))->contains('kxcdn.com')) {
58+
return $app->make(KeyCdnThumbnail::class);
59+
}
60+
61+
return $app->make(ImageKitThumbnail::class);
6062
});
6163

6264
$this->app->register(DeployServiceProvider::class);

src/Support/Thumbnails/CdnThumbnail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ abstract class CdnThumbnail extends Thumbnail
66
{
77
public function make(?int $width, ?int $height = null, bool $fit = false): ?string
88
{
9-
if($cdnUrl = str(config('ozu-client.cdn.url'))->rtrim('/')) {
9+
if($cdnUrl = str(config('ozu-client.cdn_url'))->rtrim('/')) {
1010
return sprintf(
1111
'%s/storage/%s?%s',
1212
$cdnUrl,

0 commit comments

Comments
 (0)