|
| 1 | +<?php |
| 2 | + |
| 3 | +return [ |
| 4 | + /* |
| 5 | + |-------------------------------------------------------------------------- |
| 6 | + | Source Directories |
| 7 | + |-------------------------------------------------------------------------- |
| 8 | + | |
| 9 | + | Here you may configure the directories from which the image transformer |
| 10 | + | is allowed to serve images. For security reasons, it is recommended |
| 11 | + | to only allow directories which are already publicly accessible. |
| 12 | + | |
| 13 | + | Important: The public storage directory should be addressed directly via |
| 14 | + | storage('app/public') instead of the public_path('storage') link. |
| 15 | + | |
| 16 | + | You can also use any Laravel Filesystem disk (e.g. s3) by providing an |
| 17 | + | array configuration with 'disk' and an optional 'prefix'. |
| 18 | + | |
| 19 | + */ |
| 20 | + |
| 21 | + 'source_directories' => [ |
| 22 | + 'images-test' => public_path('images'), |
| 23 | + 'storage' => storage_path('app/public/images'), |
| 24 | + 'remote' => ['disk' => 'r2'], |
| 25 | + ], |
| 26 | + |
| 27 | + /* |
| 28 | + |-------------------------------------------------------------------------- |
| 29 | + | Default Source Directory |
| 30 | + |-------------------------------------------------------------------------- |
| 31 | + | |
| 32 | + | Below you may configure the default source directory which is used when |
| 33 | + | no specific path prefix is provided in the URL. This should be one of |
| 34 | + | the keys from the source_directories array. |
| 35 | + | |
| 36 | + */ |
| 37 | + |
| 38 | + 'default_source_directory' => env('IMAGE_TRANSFORM_DEFAULT_SOURCE_DIRECTORY', 'images-test'), |
| 39 | + |
| 40 | + /* |
| 41 | + |-------------------------------------------------------------------------- |
| 42 | + | Route Prefix |
| 43 | + |-------------------------------------------------------------------------- |
| 44 | + | |
| 45 | + | Here you may configure the route prefix of the image transformer. |
| 46 | + | |
| 47 | + */ |
| 48 | + |
| 49 | + 'route_prefix' => env('IMAGE_TRANSFORM_ROUTE_PREFIX', 'image-transform'), |
| 50 | + |
| 51 | + /* |
| 52 | + |-------------------------------------------------------------------------- |
| 53 | + | Enabled Options |
| 54 | + |-------------------------------------------------------------------------- |
| 55 | + | |
| 56 | + | Here you may configure the options which are enabled for the image |
| 57 | + | transformer. |
| 58 | + | |
| 59 | + */ |
| 60 | + |
| 61 | + 'enabled_options' => env('IMAGE_TRANSFORM_ENABLED_OPTIONS', [ |
| 62 | + 'width', |
| 63 | + 'height', |
| 64 | + 'format', |
| 65 | + 'quality', |
| 66 | + 'flip', |
| 67 | + 'contrast', |
| 68 | + 'version', |
| 69 | + 'background', |
| 70 | + // 'blur' |
| 71 | + ]), |
| 72 | + |
| 73 | + /* |
| 74 | + |-------------------------------------------------------------------------- |
| 75 | + | Image Cache |
| 76 | + |-------------------------------------------------------------------------- |
| 77 | + | |
| 78 | + | Here you may configure the image cache settings. The cache is used to |
| 79 | + | store the transformed images for a certain amount of time. This is |
| 80 | + | useful to prevent reprocessing the same image multiple times. |
| 81 | + | The cache is stored in the configured cache disk. |
| 82 | + | |
| 83 | + */ |
| 84 | + |
| 85 | + 'cache' => [ |
| 86 | + 'enabled' => env('IMAGE_TRANSFORM_CACHE_ENABLED', true), |
| 87 | + 'lifetime' => env('IMAGE_TRANSFORM_CACHE_LIFETIME', 60 * 24 * 7), // 7 days |
| 88 | + 'disk' => env('IMAGE_TRANSFORM_CACHE_DISK', 'r2'), |
| 89 | + 'max_size_mb' => env('IMAGE_TRANSFORM_CACHE_MAX_SIZE_MB', 100), // 100 MB |
| 90 | + 'clear_to_percent' => env('IMAGE_TRANSFORM_CACHE_CLEAR_TO_PERCENT', 80), // 80% of max size |
| 91 | + ], |
| 92 | + |
| 93 | + /* |
| 94 | + |-------------------------------------------------------------------------- |
| 95 | + | Rate Limit |
| 96 | + |-------------------------------------------------------------------------- |
| 97 | + | |
| 98 | + | Below you may configure the rate limit which is applied for each image |
| 99 | + | new transformation by the path and IP address. It is recommended to |
| 100 | + | set this to a low value, e.g. 2 requests per minute, to prevent |
| 101 | + | abuse. |
| 102 | + | |
| 103 | + */ |
| 104 | + |
| 105 | + 'rate_limit' => [ |
| 106 | + 'enabled' => env('IMAGE_TRANSFORM_RATE_LIMIT_ENABLED', true), |
| 107 | + 'disabled_for_environments' => env('IMAGE_TRANSFORM_RATE_LIMIT_DISABLED_FOR_ENVIRONMENTS', [ |
| 108 | + 'local', |
| 109 | + 'testing', |
| 110 | + ]), |
| 111 | + 'max_attempts' => env('IMAGE_TRANSFORM_RATE_LIMIT_MAX_REQUESTS', 2), |
| 112 | + 'decay_seconds' => env('IMAGE_TRANSFORM_RATE_LIMIT_DECAY_SECONDS', 60), |
| 113 | + ], |
| 114 | + |
| 115 | + /* |
| 116 | + |-------------------------------------------------------------------------- |
| 117 | + | Signed URLs |
| 118 | + |-------------------------------------------------------------------------- |
| 119 | + | |
| 120 | + | Below you may configure signed URLs, which can be used to protect image |
| 121 | + | transformations from unauthorized access. Signature verification is |
| 122 | + | only applied to images from the for_source_directories array. |
| 123 | + | |
| 124 | + */ |
| 125 | + |
| 126 | + 'signed_urls' => [ |
| 127 | + 'enabled' => env('IMAGE_TRANSFORM_SIGNED_URLS_ENABLED', false), |
| 128 | + 'for_source_directories' => env('IMAGE_TRANSFORM_SIGNED_URLS_FOR_SOURCE_DIRECTORIES', [ |
| 129 | + // |
| 130 | + ]), |
| 131 | + ], |
| 132 | + |
| 133 | + /* |
| 134 | + |-------------------------------------------------------------------------- |
| 135 | + | Response Headers |
| 136 | + |-------------------------------------------------------------------------- |
| 137 | + | |
| 138 | + | Below you may configure the response headers which are added to the |
| 139 | + | response. This is especially useful for controlling caching behavior |
| 140 | + | of CDNs. |
| 141 | + | |
| 142 | + */ |
| 143 | + |
| 144 | + 'headers' => [ |
| 145 | + 'Cache-Control' => env('IMAGE_TRANSFORM_HEADER_CACHE_CONTROL', 'immutable, public, max-age=2592000, s-maxage=2592000'), |
| 146 | + ], |
| 147 | +]; |
0 commit comments