Skip to content
Open
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
10 changes: 9 additions & 1 deletion source/docs/v3/integrations/spatie.blade.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ The reason for this is that spatie/laravel-permission caches permissions & roles

## **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
use Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator;
use Illuminate\Support\Str;

class TenantAwareUrlGenerator extends DefaultUrlGenerator
{
Expand All @@ -87,6 +88,13 @@ class TenantAwareUrlGenerator extends DefaultUrlGenerator

return $url;
}

public function getResponsiveImagesDirectoryUrl(): string
{
$path = $this->pathGenerator->getPathForResponsiveImages($this->media);

return Str::finish(tenant_asset($path), '/');
}
}
```

Expand Down