Answers for "spatie media get url"

PHP
1

spatie media library retrieve media from url

//To retrieve files you can use the getMedia-method:
$mediaItems = $yourModel->getMedia();
//The method returns a collection of Media-objects.


//You can retrieve the url and path to the file associated with the Media-object using getUrl, getTemporaryUrl (for S3 only) and getPath:
$publicUrl = $mediaItems[0]->getUrl();
$publicFullUrl = $mediaItems[0]->getFullUrl(); //url including domain
$fullPathOnDisk = $mediaItems[0]->getPath();
$temporaryS3Url = $mediaItems[0]->getTemporaryUrl(Carbon::now()->addMinutes(5));
Posted by: Guest on September-11-2021

Browse Popular Code Answers by Language