Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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));
Source by spatie.be #
 
PREVIOUS NEXT
Tagged: #spatie #media #library #retrieve #media #url
ADD COMMENT
Topic
Name
3+8 =