Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We should fully support uploading images and image derivatives to S3, so the public file system doesn't have to be used at all.
This might require a patch to core's image.module to work around it's dependency on public:// , which if needed we should at least get into Pressflow.
Also, we should validate that we don't need access to any local filesystem beyond temp://.
Related issues:
Comment | File | Size | Author |
---|---|---|---|
#6 | 2470047.6-image-styles.patch | 18.39 KB | deviantintegral |
#3 | 2470047.3-image-styles.patch | 14.91 KB | deviantintegral |
Comments
Comment #1
deviantintegral CreditAttribution: deviantintegral at Lullabot for NBCUniversal commentedComment #2
deviantintegral CreditAttribution: deviantintegral at Lullabot for NBCUniversal commentedComment #3
deviantintegral CreditAttribution: deviantintegral at Lullabot for NBCUniversal commentedHere's a patch that re-implements image style support, without relying on the private file system. A few problems I ran into:
So how does this work?
s3://
image style URL ingetImageStyleUrl()
viaamazons3_image_style_path_alter()
. This ensures we have the proper bucket in the URL, which the default implementation doesn't get us.StreamWrapper->getExternalUrl(
). If it detects an image style, and that image style doesn't exist on S3, it will return a URL that points to our style callback atamazons3/image-derivative/...
. Otherwise, it returns a URL to S3 directly skipping the rest of this.amazons3_image_deliver()
, we first check if the derivative already exists. If it does, we 301 redirect to it.Comment #4
deviantintegral CreditAttribution: deviantintegral at Lullabot for NBCUniversal commentedAlso: This totally requires this core patch to image.module: https://www.drupal.org/node/1358896#comment-9297197
Comment #5
ericduran CreditAttribution: ericduran commentedThis is great Andrew. I'll give it a better pass tomorrow. That being said from the description this sounds awesome. Especially serving the initial one from tmp.
Comment #6
deviantintegral CreditAttribution: deviantintegral at Lullabot for NBCUniversal commentedAn update that adds:
Comment #7
ericduran CreditAttribution: ericduran commentedDoes it need full path here? Can't tell from the snippet.
I only had one small note. Everything else look great. I'm ok with merging as is.
Comment #8
deviantintegral CreditAttribution: deviantintegral at Lullabot for NBCUniversal commentedThanks!
That callback isn't a full path, but something like amazons3/image-derivative. It's a constant so I can reference it when generating image URLs.
Comment #9
deviantintegral CreditAttribution: deviantintegral at Lullabot for NBCUniversal commentedComment #11
ericduran CreditAttribution: ericduran commented@deviantintegral yea, I noticed it was a constant. I meant Full PHP path so `\Drupal\amazons3\StreamWrapper::stylesCallback` instead of `StreamWrapper::stylesCallback` assuming we were already using `use \Drupal\amazons3\StreamWrapper`
Comment #12
deviantintegral CreditAttribution: deviantintegral at Lullabot for NBCUniversal commentedOh, that! The module doesn't declare a namespace because I've seen that break things without requiring xautoload. So it's either use statements or full paths, and that class is only used once at the moment.
Comment #14
tim520 CreditAttribution: tim520 commented@deviantintegral Thanks for this great patch. But I still have some images can not be generated styles in Amazon S3, most of them are succeed.
Comment #15
jadsay CreditAttribution: jadsay commented@deviantegral: the image derivates are not being generated and uploaded to my s3 bucket only the original image is being uploaded.
I applied all the patches mentioned in the module documentation but still every image rendered with image styles is not working.
Comment #16
jadsay CreditAttribution: jadsay commentedComment #17
al.ex CreditAttribution: al.ex commented+1 confirmed that image derivate generation isn't working properly yet. I've actually resorted to trigger it manually upon changes using custom code in order to make this work somehow.
Another issue I'm facing here is that under certain circumstances, derivates aren't getting uploaded to S3. The problem is that I can't reproduce these circumstances, it seems to occur randomly. The logs don't tell anything either. Could this be related to the shutdown function implementation?
Comment #18
Kristen PolSince the last activity was 3 years ago, marking this back as fixed. If you are having trouble with this feature, please create a new issue and add steps to reproduce.