mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24:03 +00:00
📝 Add getResponsiveImagesDirectoryUrl in TenantAwareUrlGenerator
This commit is contained in:
parent
f5eb95e16b
commit
dc324488fb
1 changed files with 9 additions and 1 deletions
|
|
@ -72,10 +72,11 @@ The reason for this is that spatie/laravel-permission caches permissions & roles
|
||||||
|
|
||||||
## **laravel-medialibrary** {#laravel-medialibrary}
|
## **laravel-medialibrary** {#laravel-medialibrary}
|
||||||
|
|
||||||
To generate the correct media URLs for tenants, create a custom URL generator class extending `Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator` and override the `getUrl()` method:
|
To generate the correct media URLs for tenants, create a custom URL generator class extending `Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator` and override the `getUrl()` method and the `getResponsiveImagesDirectoryUrl` method that is used for generating URLs of responsive images.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
use Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator;
|
use Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class TenantAwareUrlGenerator extends DefaultUrlGenerator
|
class TenantAwareUrlGenerator extends DefaultUrlGenerator
|
||||||
{
|
{
|
||||||
|
|
@ -87,6 +88,13 @@ class TenantAwareUrlGenerator extends DefaultUrlGenerator
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getResponsiveImagesDirectoryUrl(): string
|
||||||
|
{
|
||||||
|
$path = $this->pathGenerator->getPathForResponsiveImages($this->media);
|
||||||
|
|
||||||
|
return Str::finish(tenant_asset($path), '/');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue