Glide image rendering service improvements #2422
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This non-breaking PR introduces new configuration and environment variables to help with Glide's integration with remote disks like S3, media library default ACL's, SVGs and transparent PNGs/GIFs support:
GLIDE_USE_SOURCE_DISK
: specify that the disk name provided inGLIDE_SOURCE_DISK
should be used as the Glide sourceGLIDE_SOURCE_DISK
: name of the disk to use as source, defaults totwill_media_library
, which is an S3 disk whenMEDIA_LIBRARY_ENDPOINT_TYPE=s3
GLIDE_USE_CACHE_DISK
: specify that the disk name provided inGLIDE_CACHE_DISK
should be used as the Glide cacheGLIDE_CACHE_DISK
: name of the disk to use as cache, defaults totwill_media_library
, which is an S3 disk whenMEDIA_LIBRARY_ENDPOINT_TYPE=s3
GLIDE_USE_STREAMED_RESPONSE_FOR_ORIGINAL_MEDIA
: Glide doesn't support SVG rendering (with both gd and imagick drivers), so we previously allowed an array of extension to bypass the Glide rendering. The problem is that by default the media library uploads are set toprivate
ACL on S3, so the S3 URL returned doesn't work. With this new setting, SVG will be returned as a streamed response from the remote disk in the Glide controllerGLIDE_USE_TEMPORARY_URL_FOR_ORIGINAL_MEDIA
: Alternatively, with compatible Flysystem disks, like S3, it is now possible to return a temporary URL with an expiring token instead of a URL that would return a 403 AccessDenied whentwill.media_library.acl
is set toprivate
. Of course, be mindful that if you are using a CDN or any sort of cache where you cache your HTML responses, you should make sure to setGLIDE_TEMPORARY_URL_EXPIRATION
to a longer duration than your cache TTL. If not, you are going to end up with expired temporary URLs in your cached HTML responses.GLIDE_TEMPORARY_URL_EXPIRATION
: Expiration in seconds for temporary URLsGLIDE_KEEP_TRANSPARENCY
: Preserves transparency for PNG and GIF files, while keeping the defaultJPG
format for everything else