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: b87b7f1

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 (b87b7f1) with main (bf62b6f)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (c5ea720) during the generation of this report, so bf62b6f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@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
@matthewp matthewp closed this Jan 30, 2026
@matthewp matthewp reopened this Jan 30, 2026
@Princesseuh Princesseuh changed the base branch from next to main January 30, 2026 18:14
@github-actions github-actions bot added feat: markdown Related to Markdown (scope) pkg: svelte Related to Svelte (scope) pkg: example Related to an example package (scope) 🚨 action Modifies GitHub Actions pkg: integration Related to any renderer integration (scope) docs pr labels Feb 2, 2026
@github-actions github-actions bot removed feat: markdown Related to Markdown (scope) pkg: svelte Related to Svelte (scope) pkg: example Related to an example package (scope) 🚨 action Modifies GitHub Actions pkg: integration Related to any renderer integration (scope) docs pr labels Feb 2, 2026
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Thanks for providing this changeset to accompany your cool feature, @rururux ! It's very helpful and well-written and explains your contribution well! 🥳

Just made some tiny suggestions for your consideration since we like to take this opportunity to hype up what you built, and why it's cool and people should use it! So, I've made some style suggestions below (in addition to adding () on functions!)

@rururux
Copy link
Contributor Author

rururux commented Feb 6, 2026

@sarah11918
Thank you for the detailed review and the kind words!
I'll update the changeset based on your suggestions! 🚀

@Princesseuh Princesseuh merged commit 3928b87 into withastro:main Feb 6, 2026
27 checks passed
@rururux
Copy link
Contributor Author

rururux commented Feb 8, 2026

Thank you so much for merging! 🥳☺️

@rururux rururux deleted the infer-remote-size branch February 8, 2026 02:20
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants