You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I upload an image, it will be added to storage/{tenant_id}/app/public. Normally, when I want to return the image URL, I just use: $mediaItems[0]->getFullUrl() or $mediaItems[0]->getUrl(), but it return an global of storage path:
Create custom UrlGenerator class extending Spatie\MediaLibrary\Support\UrlGenerator\BaseUrlGenerator,
/** When urls to files get generated, this class will be called. Use the default* if your files are stored locally above the site root or on s3.*/'url_generator' => Spatie\MediaLibrary\Support\UrlGenerator\TenantAwareUrlGenerator::class,
I think using asset helper of tenancy, something like below should work
But it helps notice that you'll likely have to implement these function: getTemporaryUrl, getPath from default URL
Generator class found in Spatie\MediaLibrary\UrlGenerator.
[Because that is mandated by abstract class Spatie\MediaLibrary\UrlGenerator\BaseUrlGenerator]
I am using this package with Spatie media library (https://docs.spatie.be/laravel-medialibrary/v8/basic-usage/retrieving-media/)
When I upload an image, it will be added to
storage/{tenant_id}/app/public
. Normally, when I want to return the image URL, I just use:$mediaItems[0]->getFullUrl()
or$mediaItems[0]->getUrl()
, but it return an global of storage path:http://domain.test/storage/16/conversions/image-medium.jpg
.Right now, I have to do some string handling to make that above URL turn to:
http://tenant.domain.test/tenancy/assets/16/conversions/image-medium.jpg
Are there any ways to make the
getFullUrl
orgetUrl
return the right URL without handle string stuff? Thank you!The text was updated successfully, but these errors were encountered: