-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Allow remark plugins to affect getImage call for .md files #9566
Conversation
🦋 Changeset detectedLatest commit: 1b35d03 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 |
Co-authored-by: Erika <[email protected]>
@Princesseuh think this should add srcset if widths or densities is passed? |
Sorry, I had actually started a review, but then I had a meeting and a network outage and completely forgot to continue 🤦♀️ I think that would be great, yes! I don't think it's super hard, should just be a check like the one done here: astro/packages/astro/components/Image.astro Lines 29 to 31 in bd3f36e
spreadAttributes should normally already handle undefined arguments.
|
Alright yeah you're right, I'll add it looking back not sure why I didn't do it initially |
If this gets accepted this plugin will make it easy to add these attributes https://www.npmjs.com/package/remark-imgattr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No accompanying docs necessary here (though, we wouldn't turn down an interesting recipe that makes use of this new functionality!)
Would ask that the changeset present a user benefit, or what will be seen/experienced though!
Co-authored-by: Sarah Rainsberger <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs is happy with the changeset!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love to see a test in core for this, because I feel like this can quickly become a source of problem.
Here's how I would do it:
- Add a fixture in
packages/astro/test/fixtures
with a remark plugin adding attributes - Add a test either in
core-image.test.js
or in a new file (core-image.test.js
is getting a bit big) inpackage/astro/test
- Confirm the attributes result in different images, you can test this in dev by making sure the
_image
URLs have the proper params.
Hi @OliverSpeir, do you think you'll have some to address the comments? |
I agree, I didn't realize this was possible will do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
Changes
__ASTRO_IMAGE__
property in rehype-images then extracts those and passes them to the getImage call in images.tsTesting
Docs