Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Image URL on GraphQL Query BUT Wait until Requested to Transform #172

Closed
1 of 3 tasks
cballenar opened this issue Sep 17, 2022 · 2 comments
Closed
1 of 3 tasks

Comments

@cballenar
Copy link

I'm submitting a...

  • bug report
  • feature request
  • general question

Description

Use case: I'm using NextJS with CraftCMS to generate static pages of posts on build. The entire list of posts and their images can be requested via GraphQL. Images don't need to be generated until requested and so the build doesn't need to slow down because of it (nor put that much work on the Craft server.

It'd be ideal if ImagerX could build a URL placeholder which is returned in the GraphQL response. Then, when the URL is accessed, the image is finally generated and returned to the user.

I imagine this would have to be an image in Craft, and if the actual image is hosted externally, then it needs to do a redirect? I'm not sure how that'd be handled...

Happy to provide more feedback and if this already exists and I missed it, really sorry, I went through the entire documentation. :)

Thanks!

@aelvan
Copy link
Contributor

aelvan commented Sep 23, 2022

If I understand correctly, this is similar to the kind of lazy transforming that I discuss in this thread way back when: aelvan/Imager-Craft#282 (comment)

In short, I won't be implementing something like this because there isn't a viable solution to this that doesn't come with some serious trade-offs.

In this case, I think several of those options are off the table anyway, as I guess NextJS would request the image during the build process in much the same way as a normal request to the Craft server? So there would be no way of knowing that the request came from the build process or not.

I would recommend instead either auto generating the transforms when content is edited, or offloading transforms to a service that does the transform in the cloud on demand (for instance Imgix or AWS Serverless Image Handler).

@cballenar
Copy link
Author

Very informative @aelvan ! I really appreciate it.

Unfortunately the options mentioned here won't work but the issue mentioned has given me some ideas to explore that may work for our setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants