Associate files with Eloquent models

Overview

Social Card of Laravel Media Library

Associate files with Eloquent models

Latest Version GitHub Workflow Status Total Downloads

This package can associate all sorts of files with Eloquent models. It provides a simple API to work with. To learn all about it, head over to the extensive documentation.

Here are a few short examples of what you can do:

$newsItem = News::find(1);
$newsItem->addMedia($pathToFile)->toMediaCollection('images');

It can handle your uploads directly:

$newsItem->addMedia($request->file('image'))->toMediaCollection('images');

Want to store some large files on another filesystem? No problem:

$newsItem->addMedia($smallFile)->toMediaCollection('downloads', 'local');
$newsItem->addMedia($bigFile)->toMediaCollection('downloads', 's3');

The storage of the files is handled by Laravel's Filesystem, so you can use any filesystem you like. Additionally the package can create image manipulations on images and pdfs that have been added in the media library.

Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Documentation

You'll find the documentation on https://docs.spatie.be/laravel-medialibrary.

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the media library? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

Testing

You can run the tests with:

vendor/bin/phpunit

Upgrading

Please see UPGRADING for details.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

A big thank you to Nicolas Beauvais for helping out with the issues on this repo.

And a special thanks to Caneco for the logo

Alternatives

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Feature wishlist for medialibrary v7

    Feature wishlist for medialibrary v7

    We are currently buillding v7 of the medialibrary. We'll work on this:

    • add Vue components to help with uploading / administering media
    • add a controller to handle requests coming from those Vue components
    • add support for responsive images / srcset (see #810)
    • uploading stuff directly to S3
    • add support for Media Collections, so you can specify how many items and what kind of items are allow in a collection
    • general cleanup

    Your ideas can help in us making medialibrary better. Feel free to add any feature requests to this issue.

    opened by freekmurze 66
  • Conversion fails after upload to S3 using MediaLibary Pro

    Conversion fails after upload to S3 using MediaLibary Pro

    Details

    • Laravel 9.5.1
    • Media Library Pro 2.1.8.

    I've been struggling with getting conversions running after uploading a file to S3. The file is upload just fine, but I get the error **Unsupported image type application/x-empty. GD driver is only able to decode JPG, PNG, GIF, BMP or WebP files.** immediately following the post.

    When I check the media table after the initial temporary upload, all data is there; however, after submitting and therefore uploading to s3, the mime_type is application/x-empty and 'size` is 0. I'm assuming the size missing creates the error in mime-type detection.

    opened by dambridge 35
  • Media Eloquent model class name is pluralized to medias

    Media Eloquent model class name is pluralized to medias

    I recognized a bug triggered by a suddenly pluralized model name media to medias which causes the query builder to run into an exception.

    [2020-05-08 18:24:56] development.ERROR: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mee2.medias' doesn't exist

    We are using Laravel 5.5.49 with version 6.9.2 of the medialibrary.

    It was working today but stopped through a breaking change somewhere. I'll look further for the cause now.

    Adding

    protected $table = 'media';

    in the model class fixes the breaking database query of course.

    opened by synthor 35
  • Temporary folders are not deleted after upload

    Temporary folders are not deleted after upload

    This happens on my localhost as well as on my production app: When uploading a file, a randomly named folder is created in storage\medialibrary\temp, containing the file. Once the upload is completed, the file is removed from that folder, but the folder itself remains.

    The permissions on that folder is 0705 and the permission on the previous folders (storage, medialibrary, and temp) are all 0755.

    This only happend since I added a new media conversion to my Model, $this->addMediaConversion('admin')

    opened by philmarc 29
  • Not installing on Laravel 6

    Not installing on Laravel 6

    I'm trying to install this package with a Fresh install of Laravel 6.

    Tried with version 7.12.0: composer require "spatie/laravel-medialibrary:^7.12.0" as it mentions "add support for Laravel 6".

    I get the following error.

    Generating optimized autoload files
    > Illuminate\Foundation\ComposerScripts::postAutoloadDump
    > @php artisan package:discover --ansi
    
       Symfony\Component\Debug\Exception\FatalThrowableError  : Class name must be a valid object or a string
    
      at D:\laragon\www\mysite\vendor\spatie\laravel-medialibrary\src\MediaLibraryServiceProvider.php:33
        29|         ], 'views');
        30|
        31|         $mediaClass = config('medialibrary.media_model');
        32|
      > 33|         $mediaClass::observe(new MediaObserver());
        34|
        35|         $this->loadViewsFrom(__DIR__.'/../resources/views', 'medialibrary');
        36|     }
        37|
    
      Exception trace:
    
      1   Spatie\MediaLibrary\MediaLibraryServiceProvider::boot()
          D:\laragon\www\mysite\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32
    
      2   call_user_func_array([])
          D:\laragon\www\mysite\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32
    
      Please use the argument -v to see more details.
    Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
    

    Can anyone help me solve this issue so I can get it up and going? Any help would be appreciated.

    opened by daugaard47 28
  • addMedia doesnt seem to work anymore

    addMedia doesnt seem to work anymore

    I am not sure but after composer update, I updated media library, and EloquentSluggable. Now the media conversations dont work anymore.

    this is my user class:

    use Illuminate\Auth\Authenticatable;
    use Illuminate\Database\Eloquent\Model;
    use Illuminate\Auth\Passwords\CanResetPassword;
    use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
    use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
    use Illuminate\Support\Facades\Hash;
    use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
    use Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia;
    use Spatie\MediaLibrary\HasMedia\Interfaces\HasMediaConversions;
    use Zizaco\Entrust\Traits\EntrustUserTrait;
    use Cviebrock\EloquentSluggable\SluggableInterface;
    use Cviebrock\EloquentSluggable\SluggableTrait;
    
    class User extends Model implements AuthenticatableContract, CanResetPasswordContract, HasMediaConversions, SluggableInterface
    {
        use Authenticatable, CanResetPassword, EntrustUserTrait, HasMediaTrait, SluggableTrait;
    
        /**
         * The database table used by the model.
         *
         * @var string
         */
        protected $table = 'users';
    
        /**
         * The attributes that are mass assignable.
         *
         * @var array
         */
        protected $fillable = ['username', 'name', 'lastname', 'email', 'password', 'city_id', 'country_id', 'verified', 'email_token'];
    
        /**
         * The attributes excluded from the model's JSON form.
         *
         * @var array
         */
        protected $hidden = ['password', 'remember_token'];
    
        protected $sluggable = [
            'build_from' => 'username',
            'save_to'    => 'slug',
            'on_update'  => true,
        ];
    
        /**
         * User profile picture conversions
         */
    
        public function registerMediaConversions()
        {
            $this->addMediaConversion('thumb')
                ->setManipulations(['w' => 60, 'h' => 60])
                ->performOnCollections('avatars');
    
            $this->addMediaConversion('medium')
                ->setManipulations(['w' => 350, 'h' => 250, 'fit' => 'crop'])
                ->performOnCollections('avatars');
        }
    

    Am I doing something wrong? every thing was working fine before the updates.

    The, what it seems, glide error I am getting now:

    Whoops, looks like something went wrong.
    
    1/1
    InvalidArgumentException in Api.php line 60:
    Not a valid manipulator.
    in Api.php line 60
    at Api->setManipulators(array(object(Orientation), object(Rectangle), object(Size), object(Brightness), object(Contrast), object(Gamma), object(Sharpen), object(Filter), object(Blur), object(Pixelate), object(Output))) in Api.php line 31
    at Api->__construct(object(ImageManager), array(object(Orientation), object(Rectangle), object(Size), object(Brightness), object(Contrast), object(Gamma), object(Sharpen), object(Filter), object(Blur), object(Pixelate), object(Output))) in GlideApiFactory.php line 43
    at GlideApiFactory::create() in GlideImage.php line 99
    at GlideImage->save('C:\wamp\www\baseapp\storage\medialibrary/temp/0oj6DPZaRxmdnbmZ/oKIX5wjtxnw4srNzthumb.jpg') in FileManipulator.php line 96
    at FileManipulator->performConversion(object(Media), object(Conversion), 'C:\wamp\www\baseapp\storage\medialibrary/temp/0oj6DPZaRxmdnbmZ/a13fqEIQjJd4yhEq.jpg') in FileManipulator.php line 65
    at FileManipulator->performConversions(object(ConversionCollection), object(Media)) in PerformConversions.php line 38
    at PerformConversions->handle()
    at call_user_func_array(array(object(PerformConversions), 'handle'), array()) in Container.php line 503
    at Container->call(array(object(PerformConversions), 'handle')) in Dispatcher.php line 193
    at Dispatcher->Illuminate\Bus\{closure}(object(PerformConversions))
    at call_user_func(object(Closure), object(PerformConversions)) in Pipeline.php line 139
    at Pipeline->Illuminate\Pipeline\{closure}(object(PerformConversions))
    at call_user_func(object(Closure), object(PerformConversions)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in Dispatcher.php line 205
    at Dispatcher->dispatchNow(object(PerformConversions), object(Closure)) in CallQueuedHandler.php line 43
    at CallQueuedHandler->call(object(SyncJob), array('command' => 'O:43:"Spatie\MediaLibrary\Jobs\PerformConversions":5:{s:14:"*conversions";O:51:"Spatie\MediaLibrary\Conversion\ConversionCollection":1:{s:8:"*items";a:2:{i:0;O:41:"Spatie\MediaLibrary\Conversion\Conversion":4:{s:7:"*name";s:5:"thumb";s:16:"*manipulations";a:1:{i:0;a:2:{s:1:"w";i:60;s:1:"h";i:60;}}s:23:"*performOnCollections";a:1:{i:0;s:7:"avatars";}s:17:"*performOnQueue";b:1;}i:1;O:41:"Spatie\MediaLibrary\Conversion\Conversion":4:{s:7:"*name";s:6:"medium";s:16:"*manipulations";a:1:{i:0;a:3:{s:1:"w";i:350;s:1:"h";i:250;s:3:"fit";s:4:"crop";}}s:23:"*performOnCollections";a:1:{i:0;s:7:"avatars";}s:17:"*performOnQueue";b:1;}}}s:8:"*media";O:45:"Illuminate\Contracts\Database\ModelIdentifier":2:{s:5:"class";s:25:"Spatie\MediaLibrary\Media";s:2:"id";i:58;}s:5:"queue";N;s:5:"delay";N;s:6:"*job";N;}')) in Job.php line 129
    at Job->resolveAndFire(array('job' => 'Illuminate\Queue\CallQueuedHandler@call', 'data' => array('command' => 'O:43:"Spatie\MediaLibrary\Jobs\PerformConversions":5:{s:14:"*conversions";O:51:"Spatie\MediaLibrary\Conversion\ConversionCollection":1:{s:8:"*items";a:2:{i:0;O:41:"Spatie\MediaLibrary\Conversion\Conversion":4:{s:7:"*name";s:5:"thumb";s:16:"*manipulations";a:1:{i:0;a:2:{s:1:"w";i:60;s:1:"h";i:60;}}s:23:"*performOnCollections";a:1:{i:0;s:7:"avatars";}s:17:"*performOnQueue";b:1;}i:1;O:41:"Spatie\MediaLibrary\Conversion\Conversion":4:{s:7:"*name";s:6:"medium";s:16:"*manipulations";a:1:{i:0;a:3:{s:1:"w";i:350;s:1:"h";i:250;s:3:"fit";s:4:"crop";}}s:23:"*performOnCollections";a:1:{i:0;s:7:"avatars";}s:17:"*performOnQueue";b:1;}}}s:8:"*media";O:45:"Illuminate\Contracts\Database\ModelIdentifier":2:{s:5:"class";s:25:"Spatie\MediaLibrary\Media";s:2:"id";i:58;}s:5:"queue";N;s:5:"delay";N;s:6:"*job";N;}'))) in SyncJob.php line 44
    at SyncJob->fire() in SyncQueue.php line 27
    at SyncQueue->push(object(PerformConversions)) in Dispatcher.php line 269
    at Dispatcher->pushCommandToQueue(object(SyncQueue), object(PerformConversions)) in Dispatcher.php line 244
    at Dispatcher->dispatchToQueue(object(PerformConversions)) in Dispatcher.php line 176
    at Dispatcher->dispatch(object(PerformConversions)) in DispatchesJobs.php line 18
    at FileManipulator->dispatch(object(PerformConversions)) in FileManipulator.php line 148
    at FileManipulator->dispatchQueuedConversions(object(Media), object(ConversionCollection)) in FileManipulator.php line 42
    at FileManipulator->createDerivedFiles(object(Media)) in Filesystem.php line 41
    at Filesystem->add('C:\wamp\tmp/php8513.tmp', object(Media), '_downloadfiles_wallpapers_1920_1200_widescreen_color_pulse_wallpaper_abstract_3d_wallpaper_1920_1200_widescreen_75.jpg') in FileAdder.php line 306
    at FileAdder->toCollectionOnDisk('avatars', 'avatars') in UsersController.php line 28
    at UsersController->avatarUpload(object(Request), 'admin')
    at call_user_func_array(array(object(UsersController), 'avatarUpload'), array(object(Request), 'slug' => 'admin')) in Controller.php line 76
    at Controller->callAction('avatarUpload', array(object(Request), 'slug' => 'admin')) in ControllerDispatcher.php line 145
    at ControllerDispatcher->call(object(UsersController), object(Route), 'avatarUpload') in ControllerDispatcher.php line 93
    at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 95
    at ControllerDispatcher->callWithinStack(object(UsersController), object(Route), object(Request), 'avatarUpload') in ControllerDispatcher.php line 54
    at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Front\UsersController', 'avatarUpload') in Route.php line 204
    at Route->runWithCustomDispatcher(object(Request)) in Route.php line 135
    at Route->run(object(Request)) in Router.php line 685
    at Router->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AuthorizeMiddleware.php line 38
    at AuthorizeMiddleware->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(AuthorizeMiddleware), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Authenticate.php line 45
    at Authenticate->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in Router.php line 687
    at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 660
    at Router->dispatchToRoute(object(Request)) in Router.php line 636
    at Router->dispatch(object(Request)) in Kernel.php line 236
    at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 64
    at VerifyCsrfToken->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
    at ShareErrorsFromSession->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
    at StartSession->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
    at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
    at EncryptCookies->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
    at CheckForMaintenanceMode->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in Kernel.php line 122
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
    at Kernel->handle(object(Request)) in index.php line 54
    

    The basic error is of course:

    InvalidArgumentException in Api.php line 60:
    Not a valid manipulator.
    

    when i dd here:

    /**
         * Set the manipulators.
         * @param array $manipulators Collection of manipulators.
         */
        public function setManipulators(array $manipulators)
        {
            foreach ($manipulators as $manipulator) {
    
                if (!($manipulator instanceof ManipulatorInterface)) {
                    dd($manipulator);
                    throw new InvalidArgumentException('Not a valid manipulator.');
                }
            }
    
            $this->manipulators = $manipulators;
        }
    

    i get:

    Orientation {#336}

    and then it throws "Not a valid manipulator"

    the conversions are still the same:

    public function registerMediaConversions()
        {
            $this->addMediaConversion('thumb')
                ->setManipulations(['w' => 60, 'h' => 60])
                ->performOnCollections('avatars');
    
            $this->addMediaConversion('medium')
                ->setManipulations(['w' => 350, 'h' => 250])
                ->performOnCollections('avatars');
        }
    
    opened by kickthemooon 28
  • getFirstMediaUrl() doesn't retrieve the full path to the file

    getFirstMediaUrl() doesn't retrieve the full path to the file

    I am using v7 of this library, when I use the method:

    echo $inmueble->getFirstMediaUrl('destacadas');

    I got this: //storage/1/1-1.jpg

    But a colleague is working on the same project also and the method shows him the full path:

    http://localhost:8888/inmuebles/public//storage/1/1-1.jpg

    Do I need to change my configuration or why I am not able to get the full path automatically?

    opened by eichgi 26
  • Error on save when conversion tries to clean up tmp dir

    Error on save when conversion tries to clean up tmp dir

    Every time I attach an image the media conversion throws an error. It looks like it's trying to delete /tmp to clean up the temp items. What am I doing wrong?

        "message": "rmdir(/tmp): Permission denied",
        "exception": "ErrorException",
        "file": "/var/www/html/ptpkg/vendor/spatie/image/src/GlideConversion.php",
        "line": 107,
    
    opened by ammonkc 25
  • I couldn't install this package with Laravel 5.7.*

    I couldn't install this package with Laravel 5.7.*

    Composer throws this message:

    Problem 1
        - Installation request for spatie/laravel-medialibrary 7.0.0 -> satisfiable by spatie/laravel-medialibrary[7.0.0].
        - Conclusion: remove laravel/framework v5.7.6
        - Conclusion: don't install laravel/framework v5.7.6
        - spatie/laravel-medialibrary 7.0.0 requires illuminate/pipeline ~5.5.0|~5.6.0 -> satisfiable by illuminate/pipeline[5.5.x-dev, 5.6.x-dev, v
    5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.6.0, v5.6.1, v5.6.
    10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.2
    6, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.4, v5.6.5, v5.6.6, v
    5.6.7, v5.6.8, v5.6.9].
        - don't install illuminate/pipeline 5.5.x-dev|don't install laravel/framework v5.7.6
    .......
    - Installation request for laravel/framework (locked at v5.7.6, required as 5.7.*) -> satisfiable by laravel/framework[v5.7.6].
    

    How can I achieve the installation?

    opened by eichgi 24
  • How can we achieve document encryption before saving files.

    How can we achieve document encryption before saving files.

    Is there a way we can integrate Laravel's Encryption mechanism with file uploads? So ideally what I'd like to achieve is before a file is uploaded we encrypt the contents and then decrypt when retrieving the document for download.

    I know it can be achieved if we store and retrieve the files manually using Storage functions like this solution but is there a way we can easily do this in this media library before storing the file like this:

    $company->addMedia($file)->toMediaCollection();

    Or if you could show me a way we can extend the Media class to achieve this?

    Thanks

    help wanted 
    opened by shabaz-ejaz 21
  • Returning files with Eloquent collection

    Returning files with Eloquent collection

    If I'm returning many rows from a database, I don't see how to getMedia for each row.

    $movies = MovieList::orderBy('sort_title', 'asc', 'release_year', 'asc') ->get(); $posterFiles = $movies->getMedia();

    Doing the above returns the error "Method getMedia does not exist".

    I can't find how to do this in the documentation.

    opened by jerauf 21
  • Unable to retrieve the mime_type for file at location when adding attachment to mailable from S3

    Unable to retrieve the mime_type for file at location when adding attachment to mailable from S3

    When adding attachments to a mailable (on S3):

            foreach ($this->model->getMedia('attachments') as $media) {
                $email->attachFromStorage($media->getTemporaryUrl(now()->addMinutes(5)), $media->name, [
                    'mime' => $media->mime_type
                ]);
            }
    

    I get this error: League\Flysystem\UnableToRetrieveMetadata Unable to retrieve the mime_type for file at location: https:/s3.[awscenter].amazonaws.com/[bucketname]/3372/print_briefpapier-%283%29.pdf?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJDNMBEEZZ221221%2Fca-central-1%2Fs3%2Faws4_request&X-Amz-Date=20221221T190223Z&X-Amz-SignedHeaders=host&X-Amz-Expires=300&X-Amz-Signature=d9b46fdf8034c7c0d67ea63f576bcb3d4ff4235c02aa8204d702b3e.

    The temp url is correctly generated. Is someone able to reproduce this?

    opened by jozeflambrecht 0
  • addFromMediaLibraryRequest() does not return instance of model

    addFromMediaLibraryRequest() does not return instance of model

    Hi, I am using MediaLibrary pro V10 and found that using addFromMediaLibraryRequest() returns null instead of the model instance of the media.

    $test = $this->category->addFromMediaLibraryRequest($this->thumbnail)->toMediaCollection('thumbnail'); dump($test); Returns null but the functions works correctly and the media becomes available in getMedia().

    opened by visbits 0
  • Downloading large multiple files using MediaStream is not working

    Downloading large multiple files using MediaStream is not working

    Downloading multiple small files in a zip as mentioned in the documentation is working good. But when I try to download large files as zipped it creates a corrupted zip

    opened by ahamed-kashif 1
  • Incorrect mime_type for mp3 files

    Incorrect mime_type for mp3 files

    I'm uploading mp3 file but, addMedia setting the mimetype as video/3gpp. Let me know any way I can manually pass proper mimetype to addMedia.

    This is what I'm using now.

    $model->addMedia($file)->toMediaCollection(config('app.name').'/voice/','s3'); What I'm referring is something like this

    $model->addMedia($file, 'audio/mpeg')->toMediaCollection(config('app.name').'/voice/','s3');

    opened by JamesPJ 0
  • No difference between getFullUrl() and getUrl() in v10 with default configuration

    No difference between getFullUrl() and getUrl() in v10 with default configuration

    Hi, I just installed this library to test it in my workflow. It works great but when I try to get the relative URL with getUrl(), without the domain name, it returns the full URL like if I called getFullUrl().

    I use the default config (not overwritten) and I just call $ad->getFirstMedia()->getUrl() in a template.

    Please ask if you need more information ! Thanks !

    opened by bistory 1
  • WebP responsive images

    WebP responsive images

    when a webp image is added no wepb responsive images are generated for media_library_original

    the problem may be here: if ($this->generateResponsiveImages && (new ImageGenerator())->canConvert($media)) {

    use Spatie\MediaLibrary\Conversions\ImageGenerators\Image as ImageGenerator; ImageGenerator instance always is an Image conversion and returns false for webp images

    is there a way to have responsive images in webp format?

    for the moment I run the job (GenerateResponsiveImagesJob) manually but it is not a good solution :(

    needs-research awaiting-response 
    opened by veneliniliev 4
Releases(10.7.5)
  • 10.7.5(Dec 30, 2022)

    What's Changed

    • Fix data corruption bug when storage disk becomes invalid by @Pilskalns in https://github.com/spatie/laravel-medialibrary/pull/3139

    New Contributors

    • @Pilskalns made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3139

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.7.4...10.7.5

    Source code(tar.gz)
    Source code(zip)
  • 10.7.4(Dec 6, 2022)

    What's Changed

    • Format workflow files by @patinthehat in https://github.com/spatie/laravel-medialibrary/pull/3115
    • Normalize composer.json by @patinthehat in https://github.com/spatie/laravel-medialibrary/pull/3114
    • Allow to clean orphaned media when the registerMediaConversionsUsingModelInstance property is set to true on the model by @tomcoonen in https://github.com/spatie/laravel-medialibrary/pull/3120

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.7.3...10.7.4

    Source code(tar.gz)
    Source code(zip)
  • 10.7.3(Nov 27, 2022)

    What's Changed

    • Issue delete command once per unique directory by @alisaleem27 in https://github.com/spatie/laravel-medialibrary/pull/3109
    • Add Dependabot Automation by @patinthehat in https://github.com/spatie/laravel-medialibrary/pull/3111
    • Bump actions/checkout from 2 to 3 by @dependabot in https://github.com/spatie/laravel-medialibrary/pull/3112
    • Throw error if disk cannot be accessed by @Silver343 in https://github.com/spatie/laravel-medialibrary/pull/3067

    New Contributors

    • @alisaleem27 made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3109
    • @dependabot made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3112
    • @Silver343 made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3067

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.7.2...10.7.3

    Source code(tar.gz)
    Source code(zip)
  • 10.7.2(Nov 22, 2022)

    What's Changed

    • [Micro Optimization] Use slice instead of reverse->take by @Tofandel in https://github.com/spatie/laravel-medialibrary/pull/3098
    • Add Additional Filename Sanitization by @patinthehat in https://github.com/spatie/laravel-medialibrary/pull/3105

    New Contributors

    • @patinthehat made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3105

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.7.1...10.7.2

    Source code(tar.gz)
    Source code(zip)
  • 10.7.1(Nov 9, 2022)

    What's Changed

    • fix #3090 syncMediaPath incorrectly comparing paths by @SlyDave in https://github.com/spatie/laravel-medialibrary/pull/3092

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.7.0...10.7.1

    Source code(tar.gz)
    Source code(zip)
  • 10.7.0(Nov 9, 2022)

    What's Changed

    • Added option to set custom queue connection by @rahulhaque in https://github.com/spatie/laravel-medialibrary/pull/3085

    New Contributors

    • @rahulhaque made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3085

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.6.1...10.7.0

    Source code(tar.gz)
    Source code(zip)
  • 9.12.4(Nov 9, 2022)

    What's Changed

    • fix #3090 - branch v9 PHP 7.4 version of the fix by @SlyDave in https://github.com/spatie/laravel-medialibrary/pull/3091

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/9.12.3...9.12.4

    Source code(tar.gz)
    Source code(zip)
  • 10.6.1(Nov 4, 2022)

    What's Changed

    • docs: fix some typos by @ArnaudLier in https://github.com/spatie/laravel-medialibrary/pull/3075
    • Fix typo in property name in Media model by @pdziewa in https://github.com/spatie/laravel-medialibrary/pull/3082

    New Contributors

    • @ArnaudLier made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3075
    • @pdziewa made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3082

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.6.0...10.6.1

    Source code(tar.gz)
    Source code(zip)
  • 10.6.0(Oct 21, 2022)

    What's Changed

    • Hint to additional installation instructions by @driesvints in https://github.com/spatie/laravel-medialibrary/pull/3047
    • PHP 8.2 Build by @erikn69 in https://github.com/spatie/laravel-medialibrary/pull/3061
    • Add fallback path/url support for conversions by @mertasan in https://github.com/spatie/laravel-medialibrary/pull/3062

    New Contributors

    • @mertasan made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3062

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.5.2...10.6.0

    Source code(tar.gz)
    Source code(zip)
  • 10.5.2(Sep 30, 2022)

    What's Changed

    • Fix for audio only "video" files by @rcerljenko in https://github.com/spatie/laravel-medialibrary/pull/3046

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.5.1...10.5.2

    Source code(tar.gz)
    Source code(zip)
  • 10.5.1(Sep 21, 2022)

    What's Changed

    • Allow the Github actions to run locally via act by @emielmolenaar in https://github.com/spatie/laravel-medialibrary/pull/3028
    • Never explicitly create directories on GCS, just as with S3 by @boboldehampsink in https://github.com/spatie/laravel-medialibrary/pull/3037

    New Contributors

    • @boboldehampsink made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3037

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.5.0...10.5.1

    Source code(tar.gz)
    Source code(zip)
  • 10.5.0(Sep 12, 2022)

    What's Changed

    • Use "request" where "response" is intended in docs by @euoia in https://github.com/spatie/laravel-medialibrary/pull/3027
    • Add getPathRelativeToRoot as a public method in the Media model by @emielmolenaar in https://github.com/spatie/laravel-medialibrary/pull/3026

    New Contributors

    • @euoia made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3027

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.4.5...10.5.0

    Source code(tar.gz)
    Source code(zip)
  • 10.4.5(Sep 2, 2022)

    What's Changed

    • Change the create method to use 'static' by @FabienLucini in https://github.com/spatie/laravel-medialibrary/pull/3021

    New Contributors

    • @FabienLucini made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3021

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.4.4...10.4.5

    Source code(tar.gz)
    Source code(zip)
  • 10.4.4(Aug 22, 2022)

    What's Changed

    • Adding a short vite description by @schonhoff in https://github.com/spatie/laravel-medialibrary/pull/3001
    • Add a note about limitation of generators by @Orrison in https://github.com/spatie/laravel-medialibrary/pull/3000
    • Update README.md to reference pest by @michaellindahl in https://github.com/spatie/laravel-medialibrary/pull/3004
    • Update CleanCommand to delete depreciated responsive images by @michaellindahl in https://github.com/spatie/laravel-medialibrary/pull/3003

    New Contributors

    • @schonhoff made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3001
    • @Orrison made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3000
    • @michaellindahl made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/3004

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.4.3...10.4.4

    Source code(tar.gz)
    Source code(zip)
  • 10.4.3(Aug 2, 2022)

  • 10.4.2(Aug 1, 2022)

    What's Changed

    • Upgrade example using JSON_EXTRACT by @erikn69 in https://github.com/spatie/laravel-medialibrary/pull/2970
    • clearMediaCollection() documentation clarification by @chimit in https://github.com/spatie/laravel-medialibrary/pull/2972
    • Added information that media wont be deleted if the deleted model use… by @titonova in https://github.com/spatie/laravel-medialibrary/pull/2993
    • Order media relationship by @Propaganistas in https://github.com/spatie/laravel-medialibrary/pull/2992

    New Contributors

    • @chimit made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2972
    • @titonova made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2993
    • @Propaganistas made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2992

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.4.1...10.4.2

    Source code(tar.gz)
    Source code(zip)
  • 10.4.1(Jun 24, 2022)

    What's Changed

    • Add @template annotation to FileAdder by @sforward in https://github.com/spatie/laravel-medialibrary/pull/2964

    New Contributors

    • @sforward made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2964

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.4.0...10.4.1

    Source code(tar.gz)
    Source code(zip)
  • 10.4.0(Jun 22, 2022)

    What's Changed

    • Update introduction.md by @trippo in https://github.com/spatie/laravel-medialibrary/pull/2951
    • Fix a typo by @bvtterfly in https://github.com/spatie/laravel-medialibrary/pull/2952
    • Update preparing-your-model.md by @timgavin in https://github.com/spatie/laravel-medialibrary/pull/2955
    • Add support for Laravel's Attachable objects by @freekmurze in https://github.com/spatie/laravel-medialibrary/pull/2963

    New Contributors

    • @bvtterfly made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2952
    • @timgavin made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2955

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.3.6...10.4.0

    Source code(tar.gz)
    Source code(zip)
  • 10.3.6(May 23, 2022)

    What's Changed

    • add webp conversion support by @Jim-Webfox in https://github.com/spatie/laravel-medialibrary/pull/2928

    New Contributors

    • @Jim-Webfox made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2928

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.3.5...10.3.6

    Source code(tar.gz)
    Source code(zip)
  • 10.3.5(May 19, 2022)

    What's Changed

    • Fix PhpStan test by @erikn69 in https://github.com/spatie/laravel-medialibrary/pull/2910
    • Fix media-library:clean command when using custom path generators by @YellowFish085 in https://github.com/spatie/laravel-medialibrary/pull/2925

    New Contributors

    • @YellowFish085 made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2925

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.3.4...10.3.5

    Source code(tar.gz)
    Source code(zip)
  • 10.3.4(May 5, 2022)

  • 10.3.3(May 3, 2022)

    What's Changed

    • Bump laravel version in docs by @karvaka in https://github.com/spatie/laravel-medialibrary/pull/2885
    • fix anchor links by @goellner in https://github.com/spatie/laravel-medialibrary/pull/2902
    • Prevent error when extracting an image from a video by @prullenbak in https://github.com/spatie/laravel-medialibrary/pull/2904

    New Contributors

    • @karvaka made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2885
    • @goellner made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2902

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.3.2...10.3.3

    Source code(tar.gz)
    Source code(zip)
  • 10.3.2(Apr 7, 2022)

    What's Changed

    • Change MediaRepository to scoped instance (Octane support) by @AlexVanderbist in https://github.com/spatie/laravel-medialibrary/pull/2876

    New Contributors

    • @JavierMartinz made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2871

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.3.1...10.3.2

    Source code(tar.gz)
    Source code(zip)
  • 9.12.3(Apr 7, 2022)

    What's Changed

    • wip by @freekmurze in https://github.com/spatie/laravel-medialibrary/pull/2851
    • Change MediaRepository to scoped instance (Octane support) by @AlexVanderbist in https://github.com/spatie/laravel-medialibrary/pull/2877

    New Contributors

    • @WouterBrouwers made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2859

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/9.12.0...9.12.3

    Source code(tar.gz)
    Source code(zip)
  • 10.3.1(Mar 31, 2022)

    What's Changed

    • Fix Htmlable render media by @Balsakup in https://github.com/spatie/laravel-medialibrary/pull/2864

    New Contributors

    • @Balsakup made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2864

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/9.12.2...10.3.1

    Source code(tar.gz)
    Source code(zip)
  • 9.12.2(Mar 24, 2022)

    What's Changed

    • Add explanation for processing responses by @SahinU88 in https://github.com/spatie/laravel-medialibrary/pull/2850
    • Update percentage value in the config file by @ClouddJR in https://github.com/spatie/laravel-medialibrary/pull/2856
    • Fix responsive url generation by @mabdullahsari in https://github.com/spatie/laravel-medialibrary/pull/2852

    New Contributors

    • @SahinU88 made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2850
    • @ClouddJR made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2856
    • @mabdullahsari made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2852

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/9.12.1...9.12.2

    Source code(tar.gz)
    Source code(zip)
  • 9.12.1(Mar 21, 2022)

    What's Changed

    • Small Typo by @Crowly34 in https://github.com/spatie/laravel-medialibrary/pull/2847

    New Contributors

    • @Crowly34 made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2847

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.3.0...9.12.1

    Source code(tar.gz)
    Source code(zip)
  • 10.3.0(Mar 18, 2022)

    What's Changed

    • Documentation improvements by @freekmurze in https://github.com/spatie/laravel-medialibrary/pull/2844
    • Added setConnection in FileAdder processMediaItem (v10) by @davidrushton in https://github.com/spatie/laravel-medialibrary/pull/2846

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.2.0...10.3.0

    Source code(tar.gz)
    Source code(zip)
  • 9.12.0(Mar 18, 2022)

    What's Changed

    • Update DefaultUrlGenerator.php by @matt127127 in https://github.com/spatie/laravel-medialibrary/pull/2837
    • Added setConnection in FileAdder processMediaItem by @davidrushton in https://github.com/spatie/laravel-medialibrary/pull/2843

    New Contributors

    • @matt127127 made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2837
    • @davidrushton made their first contribution in https://github.com/spatie/laravel-medialibrary/pull/2843

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/9.11.4...9.11.5

    Source code(tar.gz)
    Source code(zip)
  • 10.2.0(Mar 17, 2022)

    What's Changed

    • Allow path generators to be customised per model by @freekmurze in https://github.com/spatie/laravel-medialibrary/pull/2845

    Full Changelog: https://github.com/spatie/laravel-medialibrary/compare/10.1.5...10.2.0

    Source code(tar.gz)
    Source code(zip)
Owner
Spatie
We create products and courses for the developer community
Spatie
PHP runtime & extensions header files for PhpStorm

phpstorm-stubs STUBS are normal, syntactically correct PHP files that contain function & class signatures, constant definitions, etc. for all built-in

JetBrains 1.2k Dec 25, 2022
ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It's widely used to build languages, tools, and frameworks. From a grammar, ANTLR generates a parser that can build parse trees and also generates a listener interface (or visitor) that makes it easy to respond to the recognition of phrases of interest.

Antlr Project 13.6k Jan 6, 2023
Tailwind plugin to generate purge-safe.txt files

Tailwind plugin to generate safelist.txt files With tailwind-safelist-generator, you can generate a safelist.txt file for your theme based on a set of

Spatie 89 Dec 23, 2022
This small PHP package assists in the loading and parsing of VTT files.

VTT Transcriptions This small PHP package assists in the loading and parsing of VTT files. Usage use Laracasts\Transcriptions\Transcription; $transcr

Laracasts 52 Nov 28, 2022
This package used to upload files using laravel-media-library before saving model.

Laravel Media Uploader This package used to upload files using laravel-media-library before saving model. In this package all uploaded media will be p

Ahmed Fathy 312 Dec 12, 2022
A python program to cut longer MP3 files (i.e. recordings of several songs) into the individual tracks.

I'm writing a python script to cut longer MP3 files (i.e. recordings of several songs) into the individual tracks called ReCut. So far there are two

Dönerspiess 1 Oct 27, 2021
A Flysystem proxy adapter that enables compression and encryption of files and streams on the fly

Slam / flysystem-compress-and-encrypt-proxy Compress and Encrypt files and streams before saving them to the final Flysystem destination. Installation

Filippo Tessarotto 27 Jun 4, 2022
FileGator - a free, open-source, self-hosted web application for managing files and folders.

FileGator - Powerful Multi-User File Manager FileGator is a free, open-source, self-hosted web application for managing files and folders. You can man

FileGator 1.3k Jan 3, 2023
FileNamingResolver - A lightweight library which helps to resolve a file/directory naming of uploaded files using various naming strategies

FileNamingResolver - A lightweight library which helps to resolve a file/directory naming of uploaded files using various naming strategies

Victor Bocharsky 111 May 19, 2022
Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Rubik 4 May 12, 2022
Associate users with roles and permissions

Associate users with permissions and roles Sponsor If you want to quickly add authentication and authorization to Laravel projects, feel free to check

Spatie 10.9k Jan 3, 2023
Associate users with roles and permissions

Associate users with permissions and roles Sponsor If you want to quickly add authentication and authorization to Laravel projects, feel free to check

Spatie 10.9k Jan 1, 2023
This package helps you to associate users with permissions and permission groups with laravel framework

Laravel ACL This package allows you to manage user permissions and groups in a database, and is compatible with Laravel v5.8 or higher. Please check t

Mateus Junges 537 Dec 28, 2022
⚡️ Models like Eloquent for Elasticsearch.

Elasticsearch Eloquent 2.x This package allows you to interact with Elasticsearch as you interact with Eloquent models in Laravel. Requirements PHP >=

Sergey Sorokin 111 Dec 19, 2022
An Eloquent Way To Filter Laravel Models And Their Relationships

Eloquent Filter An Eloquent way to filter Eloquent Models and their relationships Introduction Lets say we want to return a list of users filtered by

Eric Tucker 1.5k Jan 7, 2023
Easy creation of slugs for your Eloquent models in Laravel

Eloquent-Sluggable Easy creation of slugs for your Eloquent models in Laravel. NOTE: These instructions are for the latest version of Laravel. If you

Colin Viebrock 3.6k Dec 30, 2022
Sortable behaviour for Eloquent models

Sortable behaviour for Eloquent models This package provides a trait that adds sortable behaviour to an Eloquent model. The value of the order column

Spatie 1.2k Dec 22, 2022
This package gives Eloquent models the ability to manage their friendships.

Laravel 5 Friendships This package gives Eloquent models the ability to manage their friendships. You can easily design a Facebook like Friend System.

Alex Kyriakidis 690 Nov 27, 2022
Automatically validating Eloquent models for Laravel

Validating, a validation trait for Laravel Validating is a trait for Laravel Eloquent models which ensures that models meet their validation criteria

Dwight Watson 955 Dec 25, 2022
Laravel Ban simplify blocking and banning Eloquent models.

Laravel Ban Introduction Laravel Ban simplify management of Eloquent model's ban. Make any model bannable in a minutes! Use case is not limited to Use

cybercog 879 Dec 30, 2022