-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Image optimization process #111
base: main
Are you sure you want to change the base?
Conversation
|
✅ Deploy Preview for astro-embed ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Thank you for the PR @sas-news! I also considered if this might be something worth exploring.
Thinking about this from the big picture, I don’t love requiring a prop to control something that in theory could be a sensible default. Especially when the prop doesn’t work without extra configuration — it’s almost always a nicer API if you only have one place to check to make sure it’s configured correctly.
I think what might make sense is:
- Always use
getImage()
under the hood. If the remote URL is not authorized,inferSize
still works, even if no optimization happens. (One case to double check would be using a non-absolute URL, e.g. if someone has an image inpublic/
, e.g.poster="/example.jpg"
should continue to work.) - Document the optimization available by adding to
image.domains
inastro.config.mjs
- (optional) Maybe services with predictable image URLs can export an array people can spread into their config if they want
I think that would match the likely use case that people want the download behaviour consistently for their whole site, not on a component-by-component basis.
What do you think?
P.S. There might also be some follow-up opportunities here. For example, often the OG images are much larger than needed (1200px wide), so if we’re using getImage()
with an authorized domain, there’s also the opportunity to resize it to a more appropriate size.
Correction of image optimization process
This allows local images to work correctly out of the box, while still providing the ability to opt-in to optimization for approved remote domains. |
downloadPoster
prop
Add a
downloadPoster
prop to YouTube and Vimeo and LinkPreview components.Download images at build time, using
getImage()
.