Add global image optimization support#3673
Conversation
|
This approach ( |
|
Hey @dannon Sure - I will reverse that commit in my "draft" PR. Yes, shortly after pushing that commit, I realized that changes to |
02eee8d to
92fb412
Compare
92fb412 to
2709543
Compare
|
Still need to update this branch & fix linting, but comments welcome. |
|
Thanks for picking this up. Image optimization is a good goal. A few questions as I look through this: In Looking at the content, all the existing frontmatter The |
Good question. The images for existing/legacy Hub is pretty undisciplined and images are found throughout various content, media, and nested directories. So, I'm thinking we have two general approaches: (1) enforce image optimization across the entire site (except for maybe one or two directories likes |
|
GPT has some thoughts on the matter - over the weekend, I can look into this one too if you think Vite-ImageTools is another good option: Option 3 — Custom Vite Plugin
|
…s and adjusts the image tags/syntax in preprocess
…s and adjusts the image tags/syntax in preprocess
…WebP image files and wraps image tags in HTML Picture tags for quick user image downloads and browser compatibility
|
Apologies for the long-winded conversation but I guess I had to think things through a bit... The latest commit takes an altogether different approach and is basically a "dev-qa" version. I am polishing it up now - fingers crossed will be able to get significant image optimization savings and help realize @dannon's vision of improved infrastructure. |
…WebP image files and wraps image tags in HTML Picture tags for quick user image downloads and browser compatibility
…WebP image files and wraps image tags in HTML Picture tags for quick user image downloads and browser compatibility
…w front matter image usage for ArticleLayout component

Addresses #3537
Simplified optimized image component.
Images must be located in the
/src/assets/directory to be optimized. Uses Astro Picture component for better browser compatibility with format fallbacks. Works for the following Astro asset types:1. Markdown (.MD) for Frontmatter image only - the default size
2. Astro (.Astro) file images
Width is target width. Height is calculated.
Sample image optimization results for 3.7 MB PNG into WebP format at 90% quality no scaling (image from this post):
Yields 95% memory improvement 🎉running locally (note: "Time" difference is likely encoding time for WebP)
Next Steps: