Skip to content

Conversation

@penalosa
Copy link

Changes

This adds a cloudflare-binding Image Service option to the Astro Cloudflare adapter. This is to support using Cloudflare images on deployments which may not have Cloudflare Images enabled on the zone (i.e. workers.dev). It's a new type rather than a replacement of the existing cloudflare image service so as not to break backwards compat (given an IMAGES binding is required in the user's wrangler.json config file.

I'm not sure if this is the right approach! Very open to changing it, but this seemed like the only way to have access to the Images binding while transforming an image. The transform() hook on an Image Service looked perfect, but I couldn't figure out how to get the Images binding accessible there.

Testing

This has been tested manually with a deployed site using a local build of the adapter.

Docs

  • This will need docs, but I wanted to align on appproach first

@changeset-bot
Copy link

changeset-bot bot commented Jun 30, 2025

⚠️ No Changeset found

Latest commit: 01bee65

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Jun 30, 2025
@ascorbic
Copy link
Contributor

ascorbic commented Jul 1, 2025

Thanks for this. We're looking to see the best way to access the binding in the image service so it can be implemented more neatly.

@alexanderniebuhr
Copy link
Member

@penalosa, thank you for this contribution. It appears to be a fantastic addition to the adapter. I conducted an initial review of the code, and overall, it seems to be in good shape. However, I’d like to explore the possibility of enhancing its integration, which would allow us to utilize the bindings more efficiently. I’ll address this matter tomorrow morning, in European time.

On a related note, could you please provide information regarding the compatibility of the IMAGES binding with both wrangler dev and platformProxy? I’m aware that the ASSETS binding is compatible with both, iirc.

@alexanderniebuhr alexanderniebuhr self-assigned this Jul 1, 2025
@penalosa
Copy link
Author

@alexanderniebuhr it's supported by wrangler dev, but not by getPlatformProxy(), it seems. I've put up a PR to Wrangler to get that fixed: cloudflare/workers-sdk#9954

@alexanderniebuhr
Copy link
Member

As already said on Discord, after trying it myself I don't seem to have a good way to access the bindings in the transform() hook. We might be able to make that possible in the future, but for now I would like to ship this as it is. @ascorbic How do we handle this. I guess this needs a Docs PR and then does it need to wait for a minor or not?

@ascorbic
Copy link
Contributor

This needs a changeset, and if possible tests

@alexanderniebuhr
Copy link
Member

I'll take this over. I want to make this the new default option. And deprecate some other options.

@penalosa
Copy link
Author

@alexanderniebuhr can this PR be closed then? Thanks for handling this!

@ascorbic
Copy link
Contributor

I think Alex will use this PR. I've already cherry-picked it into our environment API branch, so I'm expecting it will use this.

@alexanderniebuhr
Copy link
Member

@penalosa yeah sorry for being a bit quite here. I will use this PR to ship this.

@penalosa
Copy link
Author

@alexanderniebuhr is there anything I can do to help this move along?

@ascorbic
Copy link
Contributor

@alexanderniebuhr if you prefer, we can leave this as it's already in the next branch. That said, it might still be good to get it in. What do you think is outstanding to get this in?

@alexanderniebuhr
Copy link
Member

I would like to find a way to make this as similar as possible to the next branch. For users it should not be a breaking update once we use the workerd runtime. I think the change I want here is to utilize platformProxy in dev instead of our sharp implementation. I will finalize this this week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants