jgill88 / medialibrary
This package adds a small icon in the lower right of the page that allows you to upload and view your media
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 4 116
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: ~5.6|~7.0
- illuminate/support: ~5.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^1.0
- mockery/mockery: 0.9.*
- orchestra/testbench-browser-kit: ~3.1
- phpunit/phpunit: ~4.0||~5.0
This package is not auto-updated.
Last update: 2019-02-14 04:41:39 UTC
README
This package adds little icon to the lower right of your page that allows users to upload and browse their media.
Structure
src/
tests/
vendor/
Dependencies
This package has been tested on L5.4. It might be compatible with earlier versions. I'm happy to test/make work on earlier versions if anyone wants it, just ask.
You must have a file system configured. By default it uses public but can be customized as described below.
The front end uses vanilla javascript so it won't interfere with jquery or anything else you have loaded.
Classes are all prefixed with medialibrary-*
so the css shouldn't interfere either.
The package injects font-awesome 4.7.0. If this is an issue, publish the views and edit resources/vendor/jgill88/MediaLibrary/resources/views/media-bar.blade.php
to change the fontawesome include.
Install
Via Composer
$ composer require jgill88/medialibrary
Usage
Install the service provider into config/app.php provider array:
$providers = [ ..... jgill88\MediaLibrary\MediaLibraryServiceProvider::class, ], $aliases = [ ..... 'MediaLibrary' => jgill88\MediaLibrary\MediaLibraryFacade::class, ]
Once you've done this, the MediaLibrary will be injected into returned responses. It will skip JSON responses and javascript responses. Follow the steps below to configure the package.
Filesystem
The default file system is configured to use your "public" filesystem. If you haven't setup the symlink, you should:
$ php artisan storage:link
to setup your storage symlink.
Publishing vendor assets
$ php artisan publish --provider=jgill88\MediaLibrary\MediaLibraryServiceProvider
Customizing the behavior
Authenticated Users
If you would like to require authenticated users only, change:
'requireAuthentication' => true,
It is a good idea to require authentication if the app is in production mode.
By default, if authentication is required, the plugin will give each user their own media directory. It uses the email property of the authenticated user to create this directory. You can customize this by editing
//property of the user model you want to use 'authenticatedPrefix' => 'email',
Base directory
If you would like to modify the directory files are uploaded to, edit:
'directory' => 'your-base-dir-here',
in the config file, and files will be uploaded to the /your-base-dir-here/ directory.
File System
If you would like to use another filesystem besides public, just modify the name of the filesystem in the config. Make sure your filesystem is defined in config/filesystems.php.
'filesystem' => 's3',
Production
By default, the plugin is disabled in production. If you would like to enable the media library in a production environment, modify:
'disableInProduction' => false,
Again, it's probably a good idea to require authentication in this case.
Disabling the plugin
If you have a view or route that you would like to disable the plugin for, make sure you have registered the facade in app.php, and then simply include the following in your view. You can also call MediaLibrary::disable()
in your controller;
{{ MediaLibrary::disable() }}
Testing
$ composer install
$ composer test
Security
If you discover any security related issues, please email josh.dgill@gmail.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
Enhancements
- More extensible icons for file types
- Better uploaded file mimetype validation based on config
- Front end tests -- I have no experience writing front end tests. If someone does I'd definitely welcome a PR.
- Front end cleanup -- the js is not the prettiest. I would also welcome some cleanup here.
- Better DSL docblocks in the tests