Skip to content

responsive images stable #11741

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

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

responsive images stable #11741

wants to merge 20 commits into from

Conversation

sarah11918
Copy link
Member

@sarah11918 sarah11918 commented May 22, 2025

Description (required)

Un-experimentalizes responsive images!

Moves the responsive image docs (properties, guide, reference, explanations) to the proper locations throughout the stable docs.

In particular:

  • the component properties are moved to the astro:assets module page
  • the configuration reference properties are no longer named using experimental
  • the Images guide is updated to describe how the image components (and with configuration, images written with Markdown image syntax) behave when given responsive image properties
  • deletes the existing experimental reference page
  • adds image.responsiveStyles content from Add note on disabling default styles #11787 and feat: unflag responsive images astro#13917 (renamed from image.defaultStyles, defaults to false)
  • adds priority option from feat: unflag responsive images astro#13917
  • add a redirect from the experimental flag page
  • Lunaria command

Additionally, with the addition of new image content, the Image Guide itself has been slightly reorganized and lightly edited with some overall improvements:

  • colocating the "Images in X filetype" sections, since the available image options depend firstly on the type of file in which you want to add an image
  • adding a new **Options:** list at the start of each of these sections so that at a glance, it is easy to tell which image methods are available in that file type
  • creating a new <h2> to group all the "components" (<Image />, <Picture />, SVGs as components, creating a custom component (e.g. <BlogPostImage /> ) for easy reuse of images that share default settings), and removing this content from within the "Images in .astro files" section
    • Note: Originally, this grouping was to emphasize that these are Astro components, for use within .astro files. This draft instead optimizes for quickly identifying your image options based on the file type, but no longer provides all that content within that section. This allows readers to quickly see and compare how different file types work, and find the details later on the page in a dedicated section for components.
  • Updating some section headings:
    • the Image and Picture headings were too long and trying to convey too much information in the section heading
    • in fact, the Picture section heading was now "incorrect" as it was previously described as "for producing responsive images" but now we have a responsive image feature that applies to both image and picture components
    • "Setting default values" was originally worded based on having received questions about whether defaults can be set for the components. Previously, the answer was now. Now, it's "no, except for configured responsive images." Now, the section heading focuses on the solution presented: creating custom components when you want/need consistent, reusable image attributes and styles. This also is in keeping with the section now being focused on "components"
  • improvements and bug fixes

Related issues & labels (optional)

  • Closes #
  • Suggested label:

For Astro version: 5.10. See astro PR #13917. // will fill in when known

Copy link

netlify bot commented May 22, 2025

Deploy Preview for astro-docs-2 ready!

Name Link
🔨 Latest commit 6c0096e
🔍 Latest deploy log https://app.netlify.com/projects/astro-docs-2/deploys/6851d24661599900085bafc3
😎 Deploy Preview https://deploy-preview-11741--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@astrobot-houston
Copy link
Contributor

astrobot-houston commented May 22, 2025

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/guides/images.mdx Source changed, localizations will be marked as outdated.
en/reference/configuration-reference.mdx Source changed, localizations will be marked as outdated.
en/reference/experimental-flags/responsive-images.mdx Source removed, will stop being tracked.
en/reference/modules/astro-assets.mdx Source changed, localizations will be marked as outdated.
fr/reference/experimental-flags/responsive-images.mdx Localization removed, will be marked as missing. 🔄️
ko/reference/experimental-flags/responsive-images.mdx Localization removed, will be marked as missing. 🔄️
zh-cn/reference/experimental-flags/responsive-images.mdx Localization removed, will be marked as missing. 🔄️
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@ascorbic ascorbic added this to the 5.10.0 milestone Jun 6, 2025
@ascorbic
Copy link
Contributor

  • add a redirect from the experimental flag page

@sarah11918
Copy link
Member Author

add a redirect from the experimental flag page

Updated the main PR description with this checkbox!

Copy link
Member Author

@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.

@ascorbic I've left two suggestions here for handling image.responsiveStyles being true by default.

Specifically, the focus isn't on overriding the defaults anymore, but rather making sure it's clear people should opt in, and when they should avoid enabling it. Also a generic Tailwind 4 section is probably more helpful now (Yes, you can use responsive images with Tailwind 4! Here's how it works...) because the focus is not strictly about overriding.

Please feel free to edit as necessary!

Co-authored-by: Sarah Rainsberger <[email protected]>
}
});
```
You can override the `object-fit` and `object-position` styles on a per-image basis by setting the `fit` and `position` props on the `<Image />` or `<Picture />` component.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
You can override the `object-fit` and `object-position` styles on a per-image basis by setting the `fit` and `position` props on the `<Image />` or `<Picture />` component.
You can override the `object-fit` and `object-position` styles on a per-image basis by setting the `fit` and `position` props on the `<Image />` or `<Picture />` component. These props also change the way the images are cropped, so you should still use them, even if you apply your own styles.

I think this is improtant to note

Copy link
Member Author

Choose a reason for hiding this comment

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

(Addressed in the next comment)

}
});
```
You can override the `object-fit` and `object-position` styles on a per-image basis by setting the `fit` and `position` props on the `<Image />` or `<Picture />` component.
Copy link
Member Author

@sarah11918 sarah11918 Jun 12, 2025

Choose a reason for hiding this comment

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

Suggested change
You can override the `object-fit` and `object-position` styles on a per-image basis by setting the `fit` and `position` props on the `<Image />` or `<Picture />` component.
The `object-fit` and `object-position` styles determine how your images are cropped to fit their container and are essential for creating responsive images. You can override your default configuration or custom styles and provide your own styling for these properties on a per-image basis by setting the `fit` and `position` props on the `<Image />` or `<Picture />` component.

How about this, @ascorbic ? Is this "you must use them" strongly enough?

@sarah11918 sarah11918 added add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) minor-release For the next minor release; in the milestone, "merge queue" when approved by Sarah! labels Jun 12, 2025
@github-actions github-actions bot added the i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help! label Jun 12, 2025
@sarah11918 sarah11918 marked this pull request as ready for review June 12, 2025 19:55
@sarah11918
Copy link
Member Author

I think this PR has all the pieces now! (Will need a Lunaria commit message at merge)

Most recent commit adds priority reference entry. Now, it's just polishing!

@sarah11918 sarah11918 requested a review from yanthomasdev June 17, 2025 19:26
Copy link
Member

@yanthomasdev yanthomasdev left a comment

Choose a reason for hiding this comment

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

Good job. Just a few small nits. PS: This PR shouldn't need a Lunaria tracking directive, since we are not doing anything special here.

sarah11918 and others added 2 commits June 17, 2025 17:28
Co-authored-by: Yan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help! merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) minor-release For the next minor release; in the milestone, "merge queue" when approved by Sarah!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants