Enhance image rendering in custom-section and image snippet #75
+86
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improve image snippet with responsive image best practices
Summary
This PR enhances the
snippets/image.liquidsnippet to follow Shopify's performance best practices for responsive images, based on recommendations from:Changes
New Features
Responsive Image Support (
srcsetandsizes)widthsparameter to generate multiple image sizes forsrcsetsizesparameter to provide responsive display hints to the browserwidthsis not providedLoading Strategy Control
loadingparameter (defaults to'lazy'for below-fold images)'eager'for LCP images to improve Largest Contentful PaintFetch Priority Support
fetchpriorityparameter'high'for LCP images to prioritize their loadingPicture Tag for Mobile DPR Capping
use_pictureparametermobile_breakpointparameter (default: 800px)CSS Updates
<picture>tag structureBackward Compatibility
✅ All existing usage patterns continue to work without any changes. All new parameters are optional with sensible defaults.
Usage Examples
Performance Improvements
Testing with a 2000×1000px image demonstrates significant performance gains:
These improvements come from:
srcsetdelivering appropriately sized imagessizesattribute preventing oversized downloadsBenefits
loading: 'eager'andfetchpriority: 'high'optimize LCP imagesTesting
sections/product.liquid,sections/collection.liquid,sections/cart.liquid, and othersimage,url,class,width,height,crop) work as before