mediable.php
6.51 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php
return [
/*
* FQCN of the model to use for media
*
* Should extend `Plank\Mediable\Media`
*/
'model' => Plank\Mediable\Media::class,
/*
* Filesystem disk to use if none is specified
*/
'default_disk' => 'uploads',
/*
* Filesystems that can be used for media storage
*
* Uploader will throw an exception if a disk not in this list is selected
*/
'allowed_disks' => [
'uploads',
],
/*
* The maximum file size in bytes for a single uploaded file
*/
'max_size' => 1024 * 1024 * 10,
/*
* What to do if a duplicate file is uploaded.
*
* Options include:
*
* * `'increment'`: the new file's name is given an incrementing suffix
* * `'replace'` : the old file and media model is deleted
* * `'error'`: an Exception is thrown
*/
'on_duplicate' => Plank\Mediable\MediaUploader::ON_DUPLICATE_INCREMENT,
/*
* Reject files unless both their mime and extension are recognized and both match a single aggregate type
*/
'strict_type_checking' => false,
/*
* Reject files whose mime type or extension is not recognized
* if true, files will be given a type of `'other'`
*/
'allow_unrecognized_types' => false,
/*
* Only allow files with specific MIME type(s) to be uploaded
*/
'allowed_mime_types' => [],
/*
* Only allow files with specific file extension(s) to be uploaded
*/
'allowed_extensions' => [],
/*
* Only allow files matching specific aggregate type(s) to be uploaded
*/
'allowed_aggregate_types' => [],
/*
* List of aggregate types recognized by the application
*
* Each type should list the MIME types and extensions
* that should be recognized for the type
*/
'aggregate_types' => [
Plank\Mediable\Media::TYPE_IMAGE => [
'mime_types' => [
'image/jpeg',
'image/png',
'image/gif',
],
'extensions' => [
'jpg',
'jpeg',
'png',
'gif',
]
],
Plank\Mediable\Media::TYPE_IMAGE_VECTOR => [
'mime_types' => [
'image/svg+xml',
],
'extensions' => [
'svg',
]
],
Plank\Mediable\Media::TYPE_PDF => [
'mime_types' => [
'application/pdf',
],
'extensions' => [
'pdf',
]
],
Plank\Mediable\Media::TYPE_AUDIO => [
'mime_types' => [
'audio/aac',
'audio/ogg',
'audio/mpeg',
'audio/mp3',
'audio/mpeg',
'audio/wav'
],
'extensions' => [
'aac',
'ogg',
'oga',
'mp3',
'wav',
]
],
Plank\Mediable\Media::TYPE_VIDEO => [
'mime_types' => [
'video/mp4',
'video/mpeg',
'video/ogg',
'video/webm'
],
'extensions' => [
'mp4',
'm4v',
'mov',
'ogv',
'webm'
]
],
Plank\Mediable\Media::TYPE_ARCHIVE => [
'mime_types' => [
'application/zip',
'application/x-compressed-zip',
'multipart/x-zip',
],
'extensions' => [
'zip',
]
],
Plank\Mediable\Media::TYPE_DOCUMENT => [
'mime_types' => [
'text/plain',
'application/plain',
'text/xml',
'text/json',
'application/json',
'application/msword',
'application/application/vnd.openxmlformats-officedocument.wordprocessingml.document'
],
'extensions' => [
'doc',
'docx',
'txt',
'text',
'xml',
'json',
]
],
Plank\Mediable\Media::TYPE_SPREADSHEET => [
'mime_types' => [
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
],
'extensions' => [
'xls',
'xlsx',
]
],
Plank\Mediable\Media::TYPE_PRESENTATION => [
'mime_types' =>
[
'application/vnd.ms-powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
],
'extensions' =>
[
'ppt',
'pptx',
'ppsx',
]
],
],
/*
* List of adapters to use for various source inputs
*
* Adapters can map either to a class or a pattern (regex)
*/
'source_adapters' => [
'class' => [
Symfony\Component\HttpFoundation\File\UploadedFile::class => Plank\Mediable\SourceAdapters\UploadedFileAdapter::class,
Symfony\Component\HttpFoundation\File\File::class => Plank\Mediable\SourceAdapters\FileAdapter::class,
Psr\Http\Message\StreamInterface::class => Plank\Mediable\SourceAdapters\StreamAdapter::class,
],
'pattern' => [
'^https?://' => Plank\Mediable\SourceAdapters\RemoteUrlAdapter::class,
'^/' => Plank\Mediable\SourceAdapters\LocalPathAdapter::class,
'^[a-zA-Z]:\\' => Plank\Mediable\SourceAdapters\LocalPathAdapter::class
],
],
/*
* List of URL Generators to use for handling various filesystem drivers
*
*/
'url_generators' => [
'local' => Plank\Mediable\UrlGenerators\LocalUrlGenerator::class,
's3' => Plank\Mediable\UrlGenerators\S3UrlGenerator::class,
],
/**
* Should mediable instances automatically reload their media relationships after modification are made to a tag.
*
* If true, will automatically reload media the next time `getMedia()`, `getMediaMatchAll()` or `getAllMediaByTag()` are called.
*/
'rehydrate_media' => true,
/**
* Detach associated media when mediable model is soft deleted.
*/
'detach_on_soft_delete' => false,
];