media-library.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <?php
  2. use Spatie\MediaLibrary\Conversions\ImageGenerators\Image;
  3. use Spatie\MediaLibrary\Conversions\ImageGenerators\Pdf;
  4. use Spatie\MediaLibrary\Conversions\ImageGenerators\Svg;
  5. use Spatie\MediaLibrary\Conversions\ImageGenerators\Video;
  6. use Spatie\MediaLibrary\Conversions\ImageGenerators\Webp;
  7. use Spatie\MediaLibrary\Conversions\ImageGenerators\Avif;
  8. use Spatie\MediaLibrary\Conversions\Jobs\PerformConversionsJob;
  9. use Spatie\MediaLibrary\Downloaders\DefaultDownloader;
  10. use Spatie\MediaLibrary\MediaCollections\Models\Media;
  11. use Spatie\MediaLibrary\MediaCollections\Models\Observers\MediaObserver;
  12. use Spatie\MediaLibrary\ResponsiveImages\Jobs\GenerateResponsiveImagesJob;
  13. use Spatie\MediaLibrary\ResponsiveImages\TinyPlaceholderGenerator\Blurred;
  14. use Spatie\MediaLibrary\ResponsiveImages\WidthCalculator\FileSizeOptimizedWidthCalculator;
  15. use Spatie\MediaLibrary\Support\FileNamer\DefaultFileNamer;
  16. use Spatie\MediaLibrary\Support\FileRemover\DefaultFileRemover;
  17. use Spatie\MediaLibrary\Support\PathGenerator\DefaultPathGenerator;
  18. use Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator;
  19. use Spatie\MediaLibraryPro\Models\TemporaryUpload;
  20. return [
  21. /*
  22. * The disk on which to store added files and derived images by default.
  23. */
  24. 'disk_name' => env('MEDIA_DISK', 's3'),
  25. /*
  26. * The disk for conversions when not explicitly specified.
  27. */
  28. 'conversions_disk_name' => env('MEDIA_CONVERSIONS_DISK', null),
  29. /*
  30. * The maximum file size of an item in bytes.
  31. */
  32. 'max_file_size' => 1024 * 1024 * 10,
  33. /*
  34. * Disallowed file extensions.
  35. */
  36. 'disallowed_extensions' => [
  37. 'php', 'php3', 'php4', 'php5', 'php6', 'php7', 'php8',
  38. 'phtml', 'phtm', 'pht', 'phps', 'phar',
  39. 'shtml', 'shtm', 'stm',
  40. 'htaccess', 'htpasswd',
  41. 'cgi', 'pl', 'asp', 'aspx', 'jsp', 'jspx',
  42. ],
  43. /*
  44. * Allowed file extensions filter.
  45. */
  46. 'allowed_extensions' => null,
  47. /*
  48. * Queue connection for generating derived images.
  49. */
  50. 'queue_connection_name' => env('QUEUE_CONNECTION', 'sync'),
  51. /*
  52. * Queue name for generating derived images.
  53. */
  54. 'queue_name' => env('MEDIA_QUEUE', ''),
  55. /*
  56. * Queue conversions by default.
  57. */
  58. 'queue_conversions_by_default' => env('QUEUE_CONVERSIONS_BY_DEFAULT', true),
  59. /*
  60. * Should DB transactions be run after DB commits.
  61. */
  62. 'queue_conversions_after_database_commit' => env('QUEUE_CONVERSIONS_AFTER_DB_COMMIT', true),
  63. /*
  64. * The fully qualified class name of the media model.
  65. */
  66. 'media_model' => Media::class,
  67. /*
  68. * The fully qualified class name of the media observer.
  69. */
  70. 'media_observer' => MediaObserver::class,
  71. /*
  72. * Media collection serialization.
  73. */
  74. 'use_default_collection_serialization' => false,
  75. /*
  76. * Temporary upload model (Media Library Pro).
  77. */
  78. 'temporary_upload_model' => TemporaryUpload::class,
  79. /*
  80. * Enable temporary uploads session affinity.
  81. */
  82. 'enable_temporary_uploads_session_affinity' => true,
  83. /*
  84. * Generate thumbnails for temporary uploads.
  85. */
  86. 'generate_thumbnails_for_temporary_uploads' => true,
  87. /*
  88. * File namer class.
  89. */
  90. 'file_namer' => DefaultFileNamer::class,
  91. /*
  92. * Path generator class.
  93. */
  94. 'path_generator' => DefaultPathGenerator::class,
  95. /*
  96. * File remover class.
  97. */
  98. 'file_remover_class' => DefaultFileRemover::class,
  99. /*
  100. * Custom path generators per model.
  101. */
  102. 'custom_path_generators' => [],
  103. /*
  104. * URL generator class.
  105. */
  106. 'url_generator' => DefaultUrlGenerator::class,
  107. /*
  108. * Moves media on update to keep path consistent.
  109. */
  110. 'moves_media_on_update' => false,
  111. /*
  112. * Version urls with ?v=xx query string.
  113. */
  114. 'version_urls' => false,
  115. /*
  116. * Image optimizers.
  117. */
  118. 'image_optimizers' => [
  119. // Left empty - optimization handled by project's ImageUpload service
  120. ],
  121. /*
  122. * Image generators.
  123. */
  124. 'image_generators' => [
  125. Image::class,
  126. Webp::class,
  127. Avif::class,
  128. Pdf::class,
  129. Svg::class,
  130. Video::class,
  131. ],
  132. /*
  133. * Temporary directory path for image conversions.
  134. */
  135. 'temporary_directory_path' => null,
  136. /*
  137. * Image driver: gd, imagick or vips.
  138. */
  139. 'image_driver' => env('IMAGE_DRIVER', 'gd'),
  140. /*
  141. * FFMPEG paths.
  142. */
  143. 'ffmpeg_path' => env('FFMPEG_PATH', '/usr/bin/ffmpeg'),
  144. 'ffprobe_path' => env('FFPROBE_PATH', '/usr/bin/ffprobe'),
  145. /*
  146. * FFMPEG timeout in seconds.
  147. */
  148. 'ffmpeg_timeout' => env('FFMPEG_TIMEOUT', 900),
  149. /*
  150. * FFMPEG threads.
  151. */
  152. 'ffmpeg_threads' => env('FFMPEG_THREADS', 0),
  153. /*
  154. * Jobs used by the package.
  155. */
  156. 'jobs' => [
  157. 'perform_conversions' => PerformConversionsJob::class,
  158. 'generate_responsive_images' => GenerateResponsiveImagesJob::class,
  159. ],
  160. /*
  161. * Media downloader used by addMediaFromUrl.
  162. */
  163. 'media_downloader' => DefaultDownloader::class,
  164. /*
  165. * SSL verification for remote media downloads.
  166. */
  167. 'media_downloader_ssl' => env('MEDIA_DOWNLOADER_SSL', true),
  168. /*
  169. * Default lifetime in minutes for temporary URLs.
  170. */
  171. 'temporary_url_default_lifetime' => env('MEDIA_TEMPORARY_URL_DEFAULT_LIFETIME', 5),
  172. 'remote' => [
  173. 'extra_headers' => [
  174. 'CacheControl' => 'max-age=604800',
  175. ],
  176. ],
  177. 'responsive_images' => [
  178. 'width_calculator' => FileSizeOptimizedWidthCalculator::class,
  179. 'use_tiny_placeholders' => true,
  180. 'tiny_placeholder_generator' => Blurred::class,
  181. ],
  182. /*
  183. * Enable Vapor uploads for Media Library Pro.
  184. */
  185. 'enable_vapor_uploads' => env('ENABLE_MEDIA_LIBRARY_VAPOR_UPLOADS', false),
  186. /*
  187. * Default loading attribute for img tags.
  188. */
  189. 'default_loading_attribute_value' => null,
  190. /*
  191. * Storage prefix for media.
  192. */
  193. 'prefix' => env('MEDIA_PREFIX', ''),
  194. /*
  195. * Force lazy loading.
  196. */
  197. 'force_lazy_loading' => env('FORCE_MEDIA_LIBRARY_LAZY_LOADING', true),
  198. ];