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

feat: Add CSS variables in getImage for experimental.responsiveImages #13256

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

p0lyw0lf
Copy link

Changes

  • Currently, experimental.responsiveImages only adds CSS variables to images included via the <Image /> or <Picture /> components.
  • In my other PR feat: Pass remote Markdown images through image service #13254, we can only use getImage to transform images.
  • I would like to have getImage participate more fully in the responsive images experiment.
  • Moving the CSS variable logic inside getImage removes a lot of redundant/confusing logic anyways.

Testing

I tested this change by running my personal blog with it on. It provides a better outcome than when getImage is used on its own with this experiment turned on:

BeforeAfter

image

image

Note: the before pic has width: 100% applied to it in page styles. Without that, it looks even worse (no scaling applied based on page size)

Docs

We may need to update the doc page on this (https://docs.astro.build/en/reference/experimental-flags/responsive-images/), as well as the RFC (https://github.com/withastro/roadmap/blob/eff726cec3bf214b42ab13b819ed7b200753509e/proposals/0053-responsive-images.md). Currently, neither make mention of getImage being affected by this experiment.

/cc @withastro/maintainers-docs for feedback!

Copy link

changeset-bot bot commented Feb 15, 2025

🦋 Changeset detected

Latest commit: b82448a

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 Feb 15, 2025
Copy link

codspeed-hq bot commented Feb 15, 2025

CodSpeed Performance Report

Merging #13256 will not alter performance

Comparing p0lyw0lf:getimage-experiment-use-css-vars (b82448a) with main (adb58f9)

Summary

✅ 6 untouched benchmarks

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.

1 participant