diff --git a/app/Database/migrations/2018_04_02_223623_create_media_table.php b/app/Database/migrations/2018_04_02_223623_create_media_table.php new file mode 100644 index 00000000..378baef4 --- /dev/null +++ b/app/Database/migrations/2018_04_02_223623_create_media_table.php @@ -0,0 +1,38 @@ +increments('id'); + $table->morphs('model'); + $table->string('collection_name'); + $table->string('name'); + $table->string('file_name'); + $table->string('mime_type')->nullable(); + $table->string('disk'); + $table->unsignedInteger('size'); + $table->json('manipulations'); + $table->json('custom_properties'); + $table->json('responsive_images'); + $table->unsignedInteger('order_column')->nullable(); + $table->nullableTimestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down() + { + Schema::dropIfExists('media'); + } +} diff --git a/app/Http/Controllers/Admin/FileController.php b/app/Http/Controllers/Admin/FileController.php index f4d4ff37..a64a3be9 100644 --- a/app/Http/Controllers/Admin/FileController.php +++ b/app/Http/Controllers/Admin/FileController.php @@ -67,6 +67,7 @@ class FileController extends Controller * Remove the file from storage. * @param $id * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @throws \Exception */ public function destroy($id) { diff --git a/app/Support/Media/PublicUrlGenerator.php b/app/Support/Media/PublicUrlGenerator.php new file mode 100644 index 00000000..691a5128 --- /dev/null +++ b/app/Support/Media/PublicUrlGenerator.php @@ -0,0 +1,49 @@ +getPathRelativeToRoot()); + } + + /** + * Get the temporary url for a media item. + * + * @param DateTimeInterface $expiration + * @param array $options + * + * @return string + */ + public function getTemporaryUrl(DateTimeInterface $expiration, array $options = []): string + { + throw UrlCannotBeDetermined::filesystemDoesNotSupportTemporaryUrls(); + } + + /** + * Get the url to the directory containing responsive images. + * + * @return string + */ + public function getResponsiveImagesDirectoryUrl(): string + { + return public_asset('/').'/'.$this->pathGenerator->getPathForResponsiveImages($this->media); + } +} diff --git a/composer.json b/composer.json index f929c0b8..fa731a65 100755 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ "akaunting/money": "^1.0", "igaster/laravel-theme": "^2.0", "anhskohbo/no-captcha": "^3.0", - "league/csv": "^9.1" + "league/csv": "^9.1", + "spatie/laravel-medialibrary": "^7.0.0" }, "require-dev": { "phpunit/phpunit": "~7.0", diff --git a/composer.lock b/composer.lock index df496fa3..5b52b08f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "60281a4e1830c6c5a9a9338b02936d30", + "content-hash": "6b643310b61c381c247802d56e9c7348", "packages": [ { "name": "akaunting/money", @@ -168,7 +168,7 @@ "Arrilot\\Widgets\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -223,7 +223,7 @@ "Cache\\Adapter\\Common\\": "" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -291,7 +291,7 @@ "/Tests/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -353,7 +353,7 @@ "/Tests/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -408,7 +408,7 @@ "Cache\\TagInterop\\": "" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -527,7 +527,7 @@ "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -643,7 +643,7 @@ "Cron\\": "src/Cron/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -703,7 +703,7 @@ "Egulias\\EmailValidator\\": "EmailValidator" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -868,7 +868,7 @@ "src/functions_include.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -923,7 +923,7 @@ "src/functions_include.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -985,7 +985,7 @@ "Hashids\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -1079,6 +1079,76 @@ ], "time": "2018-02-12T11:19:00+00:00" }, + { + "name": "intervention/image", + "version": "2.4.1", + "source": { + "type": "git", + "url": "https://github.com/Intervention/image.git", + "reference": "3603dbcc9a17d307533473246a6c58c31cf17919" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/image/zipball/3603dbcc9a17d307533473246a6c58c31cf17919", + "reference": "3603dbcc9a17d307533473246a6c58c31cf17919", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "guzzlehttp/psr7": "~1.1", + "php": ">=5.4.0" + }, + "require-dev": { + "mockery/mockery": "~0.9.2", + "phpunit/phpunit": "^4.8 || ^5.7" + }, + "suggest": { + "ext-gd": "to use GD library based image processing.", + "ext-imagick": "to use Imagick based image processing.", + "intervention/imagecache": "Caching extension for the Intervention Image library" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + }, + "laravel": { + "providers": [ + "Intervention\\Image\\ImageServiceProvider" + ], + "aliases": { + "Image": "Intervention\\Image\\Facades\\Image" + } + } + }, + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src/Intervention/Image" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@olivervogel.com", + "homepage": "http://olivervogel.com/" + } + ], + "description": "Image handling and manipulation library with support for Laravel integration", + "homepage": "http://image.intervention.io/", + "keywords": [ + "gd", + "image", + "imagick", + "laravel", + "thumbnail", + "watermark" + ], + "time": "2017-09-21T16:29:17+00:00" + }, { "name": "irazasyed/laravel-gamp", "version": "v1.3.0", @@ -1120,7 +1190,7 @@ "Irazasyed\\LaravelGAMP\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -1167,7 +1237,7 @@ "Jackiedo\\Timezonelist\\": "src/Jackiedo/Timezonelist" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -1220,7 +1290,7 @@ "stubs/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -1271,7 +1341,7 @@ "Joshbrw\\LaravelModuleInstaller\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -1304,7 +1374,7 @@ "Traitor\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -1363,7 +1433,7 @@ "src/Laracasts/Flash/functions.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -1807,6 +1877,67 @@ ], "time": "2018-02-22T05:37:51+00:00" }, + { + "name": "league/glide", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/glide.git", + "reference": "bd29f65c9666abd72e66916e0573801e435ca878" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/glide/zipball/bd29f65c9666abd72e66916e0573801e435ca878", + "reference": "bd29f65c9666abd72e66916e0573801e435ca878", + "shasum": "" + }, + "require": { + "intervention/image": "^2.1", + "league/flysystem": "^1.0", + "php": "^5.4 | ^7.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "mockery/mockery": "~0.9", + "phpunit/php-token-stream": "^1.4", + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Glide\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Reinink", + "email": "jonathan@reinink.ca", + "homepage": "http://reinink.ca" + } + ], + "description": "Wonderfully easy on-demand image manipulation library with an HTTP based API.", + "homepage": "http://glide.thephpleague.com", + "keywords": [ + "ImageMagick", + "editing", + "gd", + "image", + "imagick", + "league", + "manipulation", + "processing" + ], + "time": "2018-02-12T23:28:25+00:00" + }, { "name": "league/iso3166", "version": "2.1.0", @@ -1839,7 +1970,7 @@ "League\\ISO3166\\": "src" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -1861,6 +1992,58 @@ ], "time": "2018-01-02T06:45:36+00:00" }, + { + "name": "maennchen/zipstream-php", + "version": "v0.4.1", + "source": { + "type": "git", + "url": "https://github.com/maennchen/ZipStream-PHP.git", + "reference": "89e0cdb3c9ecabef4da988852003781a7802afb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/89e0cdb3c9ecabef4da988852003781a7802afb7", + "reference": "89e0cdb3c9ecabef4da988852003781a7802afb7", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">= 5.6" + }, + "require-dev": { + "phpunit/phpunit": "4.3.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "ZipStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paul Duncan", + "email": "pabs@pablotron.org" + }, + { + "name": "Jesse Donat", + "email": "donatj@gmail.com" + }, + { + "name": "Jonatan Männchen", + "email": "jonatan@maennchen.ch" + } + ], + "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.", + "keywords": [ + "stream", + "zip" + ], + "time": "2016-09-13T10:29:17+00:00" + }, { "name": "markrogoyski/math-php", "version": "v0.38.0", @@ -2032,7 +2215,7 @@ "VaCentral\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -2189,7 +2372,7 @@ "src/helpers.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -2298,7 +2481,7 @@ "Http\\Discovery\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -2351,7 +2534,7 @@ "PhpUnitsOfMeasure\\": "source/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -2474,7 +2657,7 @@ "PragmaRX\\Yaml\\Tests\\": "tests/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -2535,7 +2718,7 @@ "Prettus\\Repository\\": "src/Prettus/Repository/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -2624,7 +2807,7 @@ "Psr\\Cache\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -2888,7 +3071,7 @@ "Ramsey\\Uuid\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -3140,6 +3323,188 @@ ], "time": "2017-11-05T17:39:05+00:00" }, + { + "name": "spatie/image", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/image.git", + "reference": "9ac824e02ae9ebcb6a74160d6dd9ab73a42f0e4f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/image/zipball/9ac824e02ae9ebcb6a74160d6dd9ab73a42f0e4f", + "reference": "9ac824e02ae9ebcb6a74160d6dd9ab73a42f0e4f", + "shasum": "" + }, + "require": { + "league/glide": "^1.2", + "php": "^7.0", + "spatie/image-optimizer": "^1.0", + "spatie/temporary-directory": "^1.0.0", + "symfony/process": "^3.0|^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0|^7.0", + "symfony/var-dumper": "^3.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Image\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Manipulate images with an expressive API", + "homepage": "https://github.com/spatie/image", + "keywords": [ + "image", + "spatie" + ], + "time": "2018-02-08T09:09:05+00:00" + }, + { + "name": "spatie/image-optimizer", + "version": "1.0.14", + "source": { + "type": "git", + "url": "https://github.com/spatie/image-optimizer.git", + "reference": "91603599eb29024cc9849a4a511a629ebce97850" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/image-optimizer/zipball/91603599eb29024cc9849a4a511a629ebce97850", + "reference": "91603599eb29024cc9849a4a511a629ebce97850", + "shasum": "" + }, + "require": { + "php": "^7.0", + "psr/log": "^1.0", + "symfony/process": "^2.8|^3.0|^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.2|^7.0", + "symfony/var-dumper": "^3.0|^4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\ImageOptimizer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Easily optimize images using PHP", + "homepage": "https://github.com/spatie/image-optimizer", + "keywords": [ + "image-optimizer", + "spatie" + ], + "time": "2018-03-07T13:42:33+00:00" + }, + { + "name": "spatie/laravel-medialibrary", + "version": "7.1.3", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-medialibrary.git", + "reference": "e965549f16e3b37f9c3a2ccf8021851fce62bb64" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/e965549f16e3b37f9c3a2ccf8021851fce62bb64", + "reference": "e965549f16e3b37f9c3a2ccf8021851fce62bb64", + "shasum": "" + }, + "require": { + "illuminate/bus": "~5.5.0|~5.6.0", + "illuminate/console": "~5.5.0|~5.6.0", + "illuminate/database": "~5.5.0|~5.6.0", + "illuminate/pipeline": "~5.5.0|~5.6.0", + "illuminate/support": "~5.5.0|~5.6.0", + "league/flysystem": "^1.0.8", + "maennchen/zipstream-php": "0.4.1", + "php": "^7.1", + "spatie/image": "^1.4.0", + "spatie/pdf-to-image": "^1.2", + "spatie/temporary-directory": "^1.1" + }, + "conflict": { + "php-ffmpeg/php-ffmpeg": "<0.6.1" + }, + "require-dev": { + "doctrine/dbal": "^2.5.2", + "guzzlehttp/guzzle": "^6.3", + "league/flysystem-aws-s3-v3": "^1.0.13", + "mockery/mockery": "^1.0.0", + "orchestra/testbench": "~3.5.0|~3.6.0", + "phpunit/phpunit": "^7.0", + "spatie/phpunit-snapshot-assertions": "^1.2" + }, + "suggest": { + "league/flysystem-aws-s3-v3": "Required to use AWS S3 file storage", + "php-ffmpeg/php-ffmpeg": "Required for generating video thumbnails" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\MediaLibrary\\MediaLibraryServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Spatie\\MediaLibrary\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://murze.be", + "role": "Developer" + } + ], + "description": "Associate files with Eloquent models", + "homepage": "https://github.com/spatie/laravel-medialibrary", + "keywords": [ + "cms", + "conversion", + "downloads", + "images", + "laravel", + "laravel-medialibrary", + "media", + "spatie" + ], + "time": "2018-03-30T10:46:40+00:00" + }, { "name": "spatie/laravel-pjax", "version": "1.3.2", @@ -3171,7 +3536,7 @@ "Spatie\\Pjax\\": "src" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -3192,6 +3557,102 @@ ], "time": "2018-02-06T13:21:42+00:00" }, + { + "name": "spatie/pdf-to-image", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/spatie/pdf-to-image.git", + "reference": "9a5cb264a99e87e010c65d4ece03b51f821d55bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/pdf-to-image/zipball/9a5cb264a99e87e010c65d4ece03b51f821d55bd", + "reference": "9a5cb264a99e87e010c65d4ece03b51f821d55bd", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "scrutinizer/ocular": "~1.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\PdfToImage\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Convert a pdf to an image", + "homepage": "https://github.com/spatie/pdf-to-image", + "keywords": [ + "convert", + "image", + "pdf", + "pdf-to-image", + "spatie" + ], + "time": "2016-12-14T15:37:00+00:00" + }, + { + "name": "spatie/temporary-directory", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/spatie/temporary-directory.git", + "reference": "e3da5b7a00c6610bc0b18480815fe09adf73383b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/temporary-directory/zipball/e3da5b7a00c6610bc0b18480815fe09adf73383b", + "reference": "e3da5b7a00c6610bc0b18480815fe09adf73383b", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "5.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\TemporaryDirectory\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Vanderbist", + "email": "alex@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Easily create, use and destroy temporary directories", + "homepage": "https://github.com/spatie/temporary-directory", + "keywords": [ + "spatie", + "temporary-directory" + ], + "time": "2017-09-11T08:51:13+00:00" + }, { "name": "swiftmailer/swiftmailer", "version": "v6.0.2", @@ -3822,7 +4283,7 @@ "bootstrap.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -3878,7 +4339,7 @@ "bootstrap.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -4397,7 +4858,7 @@ "TheIconic\\Tracking\\GoogleAnalytics\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -4442,7 +4903,7 @@ "TijsVerkoyen\\CssToInlineStyles\\": "src" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -4483,7 +4944,7 @@ "Tivie\\OS\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "APACHE 2.0" ], @@ -4601,7 +5062,7 @@ "src/vierbergenlars/SemVer/internal.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -4706,7 +5167,7 @@ "Webpatser\\Uuid": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -4762,7 +5223,7 @@ "/Tests/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -4833,7 +5294,7 @@ "Barryvdh\\LaravelIdeHelper\\": "src" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -5041,7 +5502,7 @@ "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -5098,7 +5559,7 @@ "Whoops\\": "src/Whoops/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -5303,7 +5764,7 @@ "JakubOnderka\\PhpConsoleColor": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "BSD-2-Clause" ], @@ -5347,7 +5808,7 @@ "JakubOnderka\\PhpConsoleHighlighter": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -5456,7 +5917,7 @@ "src/DeepCopy/deep_copy.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -5726,7 +6187,7 @@ ] } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -5822,7 +6283,7 @@ "Prophecy\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -5892,7 +6353,7 @@ "src/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -5940,7 +6401,7 @@ "src/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -6031,7 +6492,7 @@ "src/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -6081,7 +6542,7 @@ "src/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -6215,7 +6676,7 @@ "src/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -6312,7 +6773,7 @@ "src/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -6375,7 +6836,7 @@ "src/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -6925,7 +7386,7 @@ "Webmozart\\Assert\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], diff --git a/config/medialibrary.php b/config/medialibrary.php new file mode 100644 index 00000000..00157fa5 --- /dev/null +++ b/config/medialibrary.php @@ -0,0 +1,140 @@ + 'public', + + /* + * The maximum file size of an item in bytes. + * Adding a larger file will result in an exception. + */ + 'max_file_size' => 1024 * 1024 * 10, + + /* + * This queue will be used to generate derived and responsive images. + * Leave empty to use the default queue. + */ + 'queue_name' => '', + + /* + * The class names of the models that should be used. + */ + 'media_model' => Spatie\MediaLibrary\Models\Media::class, + + 's3' => [ + /* + * The domain that should be prepended when generating urls. + */ + 'domain' => 'https://'.env('AWS_BUCKET').'.s3.amazonaws.com', + ], + + 'remote' => [ + /* + * Any extra headers that should be included when uploading media to + * a remote disk. Even though supported headers may vary between + * different drivers, a sensible default has been provided. + * + * Supported by S3: CacheControl, Expires, StorageClass, + * ServerSideEncryption, Metadata, ACL, ContentEncoding + */ + 'extra_headers' => [ + 'CacheControl' => 'max-age=604800', + ], + ], + + 'responsive_images' => [ + + /* + * This class is responsible for calculating the target widths of the responsive + * images. By default we optimize for filesize and create variations that each are 20% + * smaller than the previous one. More info in the documentation. + * + * https://docs.spatie.be/laravel-medialibrary/v7/advanced-usage/generating-responsive-images + */ + 'width_calculator' => Spatie\MediaLibrary\ResponsiveImages\WidthCalculator\FileSizeOptimizedWidthCalculator::class, + + /* + * By default rendering media to a responsive image will add some javascript and a tiny placeholder. + * This ensures that the browser can already determine the correct layout. + */ + 'use_tiny_placeholders' => true, + + /* + * This class will generate the tiny placeholder used for progressive image loading. By default + * the medialibrary will use a tiny blurred jpg image. + */ + 'tiny_placeholder_generator' => Spatie\MediaLibrary\ResponsiveImages\TinyPlaceholderGenerator\Blurred::class, + ], + + /* + * When urls to files get generated, this class will be called. Leave empty + * if your files are stored locally above the site root or on s3. + */ + 'url_generator' => \App\Support\Media\PublicUrlGenerator::class, + + /* + * The class that contains the strategy for determining a media file's path. + */ + 'path_generator' => null, + + /* + * Medialibrary will try to optimize all converted images by removing + * metadata and applying a little bit of compression. These are + * the optimizers that will be used by default. + */ + 'image_optimizers' => [ + Spatie\ImageOptimizer\Optimizers\Jpegoptim::class => [ + '--strip-all', // this strips out all text information such as comments and EXIF data + '--all-progressive', // this will make sure the resulting image is a progressive one + ], + Spatie\ImageOptimizer\Optimizers\Pngquant::class => [ + '--force', // required parameter for this package + ], + Spatie\ImageOptimizer\Optimizers\Optipng::class => [ + '-i0', // this will result in a non-interlaced, progressive scanned image + '-o2', // this set the optimization level to two (multiple IDAT compression trials) + '-quiet', // required parameter for this package + ], + Spatie\ImageOptimizer\Optimizers\Svgo::class => [ + '--disable=cleanupIDs', // disabling because it is known to cause troubles + ], + Spatie\ImageOptimizer\Optimizers\Gifsicle::class => [ + '-b', // required parameter for this package + '-O3', // this produces the slowest but best results + ], + ], + + /* + * These generators will be used to create an image of media files. + */ + 'image_generators' => [ + Spatie\MediaLibrary\ImageGenerators\FileTypes\Image::class, + Spatie\MediaLibrary\ImageGenerators\FileTypes\Pdf::class, + Spatie\MediaLibrary\ImageGenerators\FileTypes\Svg::class, + Spatie\MediaLibrary\ImageGenerators\FileTypes\Video::class, + ], + + /* + * The engine that should perform the image conversions. + * Should be either `gd` or `imagick`. + */ + 'image_driver' => 'gd', + + /* + * FFMPEG & FFProbe binaries paths, only used if you try to generate video + * thumbnails and have installed the php-ffmpeg/php-ffmpeg composer + * dependency. + */ + 'ffmpeg_path' => env('FFMPEG_PATH', '/usr/bin/ffmpeg'), + 'ffprobe_path' => env('FFPROBE_PATH', '/usr/bin/ffmpeg'), + + /* + * The path where to store temporary files while performing image conversions. + * If set to null, storage_path('medialibrary/temp') will be used. + */ + 'temporary_directory_path' => null, +];