Skip to content

fix: passthroughImageService generate webp#14776

Merged
Princesseuh merged 6 commits intowithastro:mainfrom
ktym4a:fix/noop-image-service
Nov 17, 2025
Merged

fix: passthroughImageService generate webp#14776
Princesseuh merged 6 commits intowithastro:mainfrom
ktym4a:fix/noop-image-service

Conversation

@ktym4a
Copy link
Contributor

@ktym4a ktym4a commented Nov 16, 2025

Changes

Close #14721

  • Fixed an issue which passthroughImageService was generating images in WebP format.
  • Change to not call validateOptions when ESMImportedImage

Testing

  • Added fixture and test code

Docs

  • I don't think we need to add, but Behavior is changed.

@changeset-bot
Copy link

changeset-bot bot commented Nov 16, 2025

🦋 Changeset detected

Latest commit: 39c2469

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 Nov 16, 2025
Comment on lines 8 to 16
validateOptions(options, imageConfig) {
if (isESMImportedImage(options.src)) {
return {
src: options.src,
format: options.src.format,
};
}
return baseService.validateOptions?.(options, imageConfig) ?? options;
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if we should just override format then pass to validateOptions something like this.

if (isESMImportedImage(options.src)) {
    options.format = options.src.format;
}
return baseService.validateOptions?.(options, imageConfig) ?? options;

Copy link
Member

Choose a reason for hiding this comment

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

I don't 100% remember this code, but would this work?

Suggested change
validateOptions(options, imageConfig) {
if (isESMImportedImage(options.src)) {
return {
src: options.src,
format: options.src.format,
};
}
return baseService.validateOptions?.(options, imageConfig) ?? options;
},
validateOptions(options, imageConfig) {
const newOptions = baseService.validateOptions?.(options, imageConfig) ?? options;
delete newOptions.format;
return newOptions;
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Princesseuh
thanks!
it works, so I changed to 39c2469

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 16, 2025

CodSpeed Performance Report

Merging #14776 will not alter performance

Comparing ktym4a:fix/noop-image-service (39c2469) with main (504958f)1

Summary

✅ 6 untouched

Footnotes

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

@ktym4a ktym4a requested a review from Princesseuh November 17, 2025 16:40
@Princesseuh
Copy link
Member

Test failure looks unrelated, awesome work

@Princesseuh Princesseuh merged commit 3537876 into withastro:main Nov 17, 2025
26 of 27 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Nov 17, 2025
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.

passthroughImageService() does not prevent WebP conversion for Image component in Astro 5.15.2

2 participants