Questions tagged [laravel-medialibrary]

Laravel-medialibrary is a popular Laravel package to associate media files with eloquent ORM models

Useful links:

105 questions
0
votes
0 answers

How to display responsive background images with Laravel media library?

I'm saving an Image when creating a post in my controller using the code below: $post->addMedia($file)->withResponsiveImages()->toMediaCollection(); And displaying the responsive images in my blade file with: {{ $post->getFirstMedia() }} This works…
Alphy Gacheru
  • 489
  • 1
  • 9
  • 28
0
votes
0 answers

Spatie MediaLibrary Public Property

I am using Spatie MediaLibrary to upload documents into the database and right now I face an issue. Spatie uses public property $mediaComponentNames where I have to assign the media name. For example: public $mediaComponentNames = ['myUpload']; The…
qir4ni
  • 1
  • 1
0
votes
0 answers

File `{$path}` does not exist error in media library laravel

Can I save image for 2 tables in db with same file request? in controller $combo = new Combo; if ($request->hasFile('image') && $request->file('image')->isValid()) { …
0
votes
0 answers

How to add media conversion to existing media instance

I have my existing $media instance and I would like to generate a thumbnail at $seconds. I tried: $media->manipulations = [ 'thumb' => [ 'height' => '250', 'extractVideoFrameAtSecond' => $seconds, ], ]; $media->save(); But get this…
user3253002
  • 1,521
  • 3
  • 21
  • 43
0
votes
1 answer

Laravel Media Library Expected the file to have mimetype image/jpeg, but found a file with mimetype image/png

I have a news aggregator site that grabs an image from a remote URL but the script is breaking with the following error when I try to crop the file after grabbing: Expected the file at…
0
votes
0 answers

Laravel Media Library Repeating same value for file_description field

I have an array of file upload inputs, When I upload files in each and submit, the files get uploaded adequately, and in the media table, teach gets inserted with the correct file name, file path etc except the file_description field that saves same…
Ola
  • 1
  • 3
0
votes
1 answer

Why spatie/laravel-medialibrary raise error on uploding image uploaded with faker-images?

I added https://github.com/morawskim/faker-images to laravel 9 site and when I try get image from this lib and to upload it with Medialibrary $faker = \Faker\Factory::create(); $faker->addProvider(new…
Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91
0
votes
1 answer

Laravel Media Library: How to get model from custom property?

Using Laravel Media Library, User 1 can send an image to User 2. User 1's user ID is stored as a custom property in the media collection: 'from_user_id' When retrieving user 2's images, how do I get the model for User 1 so that I can display their…
timgavin
  • 4,972
  • 4
  • 36
  • 48
0
votes
1 answer

Laravel Spatie Media Library Version 9 Trait not found

I am using: "php": "^8.0.2", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^9.19", "laravel/sanctum": "^2.14.1", "laravel/tinker": "^2.7", "laravel/ui": "^3.4", "laravelcollective/html": "^6.3", "spatie/laravel-medialibrary":…
Yunus Aslam
  • 2,447
  • 4
  • 25
  • 39
0
votes
1 answer

Download all files in laravel media library without collection name

I'm trying to download all the uploads together under one user. If one user has uploaded under multiple collections, I want to download all uploads under all collections in one click as a zip file. I tried without the collection name in getMedia…
ManUtd
  • 23
  • 1
  • 8
0
votes
1 answer

spatie/laravel-medialibrary, filters on getMedia() function not working

I am trying to get media for certain modal as follows: public function show(Gallery $gallery) { $images = $gallery->getMedia('default'); //returns images // $images = $gallery->getMedia('default', ['name', 'original_url']);…
0
votes
1 answer

How to add image to specific Media Collection Conversion with Laravel-medialibrary?

I have two input image in my form, and one registerMediaConversions : public function registerMediaConversions(Media $media = null) : void { $this->addMediaConversion('big') ->performOnCollections('category-cover'); …
0
votes
1 answer

Laravel-medialibrary: How to set owner of files and conversions?

Problem is, that image files cannot be deleted via GUI, since the owner of the files is root (some images are created by a cronjob directly. There are also the conversions generated by medialibrary itself within a Laravel job.). I did not find a way…
Leif
  • 2,143
  • 2
  • 15
  • 26
0
votes
0 answers

Spatie Media Library - Array to string conversion

I am trying to get Spatie Media Library to work, but I have this error: I really don't know where it comes from, any suggestions? I'll leave a copy of the portion of the code where the error happens Str.php /** * Replace the given value in the…
0
votes
4 answers

Laravel polymorphic relationship retrieve last record

I am currently using the Spatie media library and I have created my own custom class as follows: use Spatie\MediaLibrary\Models\Media as BaseMedia; class TrybzMedia extends BaseMedia { protected $table = 'media'; protected $appends =…