Skip to content

Conversation

@rururux
Copy link
Contributor

@rururux rururux commented Jan 17, 2026

Changes

As discussed in the issue #14515 and #15067, the current implementation of inferRemoteSize had the problem of increased network traffic because it did not cache data.
To address this issue, I added a getRemoteSize property to the Image Service and implemented the publicly exposed inferRemoteSize API to utilize this property.
Additionally, for baseService's getRemoteSize, I configured a function that simply wraps the existing inferRemoteSize. This ensures no breaking changes occur for users who do not wish to see their behavior altered.

  • Set getRemoteSize as an API of the Image Service.
  • Modified the publicly exposed inferRemoteSize function to utilize the Image Service's getRemoteSize.
  • Assigned the existing inferRemoteSize function to baseService's getRemoteSize. This prevents breaking changes and facilitates easy, lightweight extensions based on the existing implementation.

Testing

I implemented tests to verify that arbitrary processing can be configured and that delegation from baseService to the original inferRemoteSize is possible.

Docs

Since we are setting the existing inferRemoteSize as the default value, I don't believe this constitutes a breaking change. However, since we will be introducing a new property called getRemoteSize in the Image Service, I think the documentation will need to be updated.

/cc @withastro/maintainers-docs

As this is a PR introducing a new property, I would like to hear the opinions of the maintainers regarding this approach. Therefore, I will submit this PR as a draft for now.

@changeset-bot
Copy link

changeset-bot bot commented Jan 17, 2026

🦋 Changeset detected

Latest commit: 9d842f8

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jan 17, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 17, 2026

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing rururux:infer-remote-size (9d842f8) with main (955edb9)

Open in CodSpeed
@rururux rururux marked this pull request as ready for review January 21, 2026 11:43
Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this! It'll need a changeset and a docs PR to this page: https://docs.astro.build/en/reference/image-service-reference/. However, just a heads up that we'll be freezing main very soon, so this might only land in v6, which would take a month or two to be stable.

@Princesseuh Princesseuh self-assigned this Jan 21, 2026
@rururux
Copy link
Contributor Author

rururux commented Jan 22, 2026

Understood. Thank you for the review and the approval!

Regarding the changeset, should I create it as a minor change, or would patch be sufficient for this case?

@Princesseuh
Copy link
Member

It'll need to be a minor since it's a new feature!

@rururux
Copy link
Contributor Author

rururux commented Jan 23, 2026

Thank you, I've added it.

@rururux
Copy link
Contributor Author

rururux commented Jan 23, 2026

I previously brought over the comment for getRemoteSize from inferRemoteSize, but looking at it again, it doesn't feel like the right fit for a property in the Image Service interface.

I’d like to update it to the following to better match the other properties. what do you think?

/**
 * Return the dimensions of a remote image.
 *
 * This is used to infer the width and height of an image from its URL,
 * allowing the service to provide necessary metadata when it's not available locally.
 */
getRemoteSize?: (...) => 
@rururux
Copy link
Contributor Author

rururux commented Jan 23, 2026

Also, I should probably rewrite the changeset as well. My apologies.

@rururux
Copy link
Contributor Author

rururux commented Jan 25, 2026

I've updated the comments and the changeset.
Please take a look when you have a chance.

@Princesseuh
Copy link
Member

Hello! Apologies for the delayed response. This looks great! We're currently preparing for 6.x, so this will probably have to wait until we're ready for that to be merged.

@rururux
Copy link
Contributor Author

rururux commented Jan 30, 2026

Thank you!
I was just trying to see if I could change the base branch from main to next.
Which would be better, leaving it as main or rebasing it to next?

@Princesseuh
Copy link
Member

If you have time rebasing onto next would be amazing!

@github-actions github-actions bot added feat: markdown Related to Markdown (scope) pkg: svelte Related to Svelte (scope) pkg: vue Related to Vue (scope) pkg: example Related to an example package (scope) 🚨 action Modifies GitHub Actions pkg: react Related to React (scope) pkg: preact Related to Preact (scope) pkg: solid Related to Solid (scope) pkg: integration Related to any renderer integration (scope) pkg: create-astro Related to the `create-astro` package (scope) labels Jan 30, 2026
@rururux rururux changed the base branch from main to next January 30, 2026 13:28
@rururux
Copy link
Contributor Author

rururux commented Jan 30, 2026

Whoops, I must have done something wrong, a bunch of labels got added.
My apologies. 😅

@github-actions github-actions bot removed feat: markdown Related to Markdown (scope) pkg: svelte Related to Svelte (scope) pkg: vue Related to Vue (scope) pkg: example Related to an example package (scope) 🚨 action Modifies GitHub Actions pkg: react Related to React (scope) pkg: preact Related to Preact (scope) pkg: solid Related to Solid (scope) pkg: integration Related to any renderer integration (scope) pkg: create-astro Related to the `create-astro` package (scope) docs pr labels Jan 30, 2026
@github-actions
Copy link
Contributor

⚠️ Package Trust Level Decreased

Caution

Decreased trust levels may indicate a higher risk of supply chain attacks. Please review these changes carefully.

📦 Package 🔒 Before 🔓 After
eslint-plugin-regexp trusted-with-provenance none
@cloudflare/kv-asset-handler trusted-with-provenance none
@cloudflare/unenv-preset trusted-with-provenance none
workerd trusted-with-provenance none
@sveltejs/vite-plugin-svelte-inspector trusted-with-provenance provenance
@sveltejs/vite-plugin-svelte trusted-with-provenance provenance
jsdoc-type-pratt-parser trusted-with-provenance none
miniflare trusted-with-provenance none
youch provenance none
@cloudflare/workerd-darwin-64 trusted-with-provenance none
@cloudflare/workerd-darwin-arm64 trusted-with-provenance none
@cloudflare/workerd-linux-64 trusted-with-provenance none
@cloudflare/workerd-linux-arm64 trusted-with-provenance none
@cloudflare/workerd-windows-64 trusted-with-provenance none
wrangler trusted-with-provenance none
@Princesseuh
Copy link
Member

Only thing left is gonna be the PR to https://github.com/withastro/docs/ to update this page https://docs.astro.build/en/reference/image-service-reference/ ! Please target the v6 branch there.

@Princesseuh Princesseuh changed the base branch from next to main January 30, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

3 participants