- @dieterholvoet opened merge request.
- Status changed to Needs review
over 1 year ago 8:42pm 4 May 2023 - π§πͺBelgium dieterholvoet Brussels
I encountered the same issue and after doing some research I came across β¨ Support delivering local image styles until remote upload is complete Needs work , an effort to fix this issue for all Flysystem adapters at once. Basically, what it does is this:
- If an non-existent image derivative is requested (any path starting with
styles/
), a temporary URL is generated to a Flysystem Drupal route (flysystem.image_style_redirect.serve
). This URL is returned to the browser instead of the direct image URL. - The browser requests this URL to get the image.
- A check is done to make sure the source image exists. If it doesn't, a 404 is returned and no further action is taken
- If in the meantime the image derivative was created (should be rare), redirect to the GCS URL.
- If the image still doesn't exist, generate the derivative and store it locally in a temporary folder. The temporary file
- is now sent to the browser without having to go through GCS. Once the response is sent and the image is displayed in the browser, Drupal will copy the temporary image to GCS.
- If the image is requested again and the temporary file still exists, that file is returned, which saves us a trip to GCS.
- Once the temporary file is copied to GCS, that url will be sent to the browser instead of the Flysystem Drupal route (
flysystem.image_style_redirect.serve
).
In order to test this code you need to apply the merge request from β¨ Support delivering local image styles until remote upload is complete Needs work to your version of the flysystem module and the merge request from this issue to your version of the flysystem_gcs module. When leaving feedback, please do so first in the flysystem issue since this feature is largely being built over there.
- If an non-existent image derivative is requested (any path starting with