forked from outl1ne/nova-media-hub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnova-media-hub.php
156 lines (128 loc) · 5.53 KB
/
nova-media-hub.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
use Outl1ne\NovaMediaHub\MediaHandler\Support\FileNamer;
use Outl1ne\NovaMediaHub\MediaHandler\Support\FileValidator;
use Outl1ne\NovaMediaHub\MediaHandler\Support\MediaManipulator;
use Outl1ne\NovaMediaHub\MediaHandler\Support\PathMaker;
use Outl1ne\NovaMediaHub\Models\Media;
use Spatie\Image\Manipulations;
return [
// Table name
'table_name' => 'media_hub',
// Base URL path in Nova
'base_path' => 'media-hub',
// Classes configuration
'model' => Media::class,
'file_namer' => FileNamer::class,
'file_validator' => FileValidator::class,
'media_manipulator' => MediaManipulator::class,
// This default PathMaker puts files in a /prefix/<mediaid>/* structure
'path_maker' => PathMaker::class,
// If you want files to be in a /prefix/year/month/<mediaid>/* folder structure, use DatePathMaker instead
// 'path_maker' => \Outl1ne\NovaMediaHub\MediaHandler\Support\DatePathMaker::class,
// Disk configurations
'disk_name' => 'public',
'conversions_disk_name' => 'public',
// Path configuration
'path_prefix' => 'media',
// Locales (for translatable alt texts and titles)
// Set to null if you don't want translatability
// Example value: ['et' => 'Estonian', 'en' => 'English']
'locales' => null,
// File size upper limit
'max_uploaded_file_size_in_kb' => 15000,
// Allowed mime types list
'allowed_mime_types' => [
'image/jpeg',
'image/png',
'image/gif',
'image/svg+xml',
'image/webp',
'video/mp4',
'text/csv',
'application/pdf',
],
// Job queue configuration
'original_image_manipulations_job_queue' => null,
'image_conversions_job_queue' => null,
// Default collections that will always be displayed (even when empty)
'collections' => [
'default',
],
// Defines whether user can create collections in the "Upload media" modal
// If set to false, the user can only use the collections defined in the config
'user_can_create_collections' => true,
// Thumbnail conversion name
// If you want Nova to use thumbnails instead of full size files
// when dispalying media, define the name of the conversion here
'thumbnail_conversion_name' => null,
// Image manipulation driver
// If null, it will try to read config('image.driver')
// Final fallback is 'gd'
// Options: null, 'imagick', 'gd'
'image_driver' => null,
// -- Conversions
// 'collection_name' => ['conversion_name' => [options]]
// Use '*' as wildcard for all collections
'image_conversions' => [
'*' => [
// Disable oiriginal image optimizations on a per-collection basis
// Only accepts 'false' as an argument to disable original image manipulations
// 'original' => false,
'thumbnail' => [
// Image format, null for same as original
// Other options: jpg, pjpg, png, gif, webp, avif, tiff
'format' => null,
'width' => 150,
'height' => 150,
'fit' => Manipulations::FIT_MAX,
],
],
],
'original_image_manipulations' => [
// Set to false if you don't want the original image to be optimized
// The mime type must still be in the optimizable_mime_types array
// If set to false, will also disable resizing in max_dimensions
'optimize' => true,
// Maximum number of pixels in height or width, will be scaled down to this number
// Set to null if you don't want the original image to be resized
'max_dimensions' => 2000,
],
// ------------------------------
// -- Image optimizations
// ------------------------------
// NB! Must have a matching image_optimizer configured and binary for it to work
'optimizable_mime_types' => [
'image/jpeg',
// 'image/png',
// 'image/gif',
],
'image_optimizers' => [
Spatie\ImageOptimizer\Optimizers\Jpegoptim::class => [
'-m85', // set maximum quality to 85%
'--force', // ensure that progressive generation is always done also if a little bigger
'--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
],
Spatie\ImageOptimizer\Optimizers\Cwebp::class => [
'-m 6', // for the slowest compression method in order to get the best compression.
'-pass 10', // for maximizing the amount of analysis pass.
'-mt', // multithreading for some speed improvements.
'-q 90', //quality factor that brings the least noticeable changes.
],
],
];