-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat: add asImageSrc
, asImageWidthSrcSet
, asImagePixelDensitySrcSet
#38
Conversation
Codecov Report
@@ Coverage Diff @@
## master #38 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 13 +3
Lines 154 188 +34
Branches 30 39 +9
=========================================
+ Hits 154 188 +34
Continue to review full report at Codecov.
|
asImageSrc
, asImageWidthSrcSet
, asImagePixelDensitiesSrcSet
asImageSrc
, asImageWidthSrcSet
, asImagePixelDensitySrcSet
size-limit report 📦
|
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.
Looking very good! Some questions / minor stuff but feel free to proceed beyond
field: Field, | ||
params: ImgixURLParams = {}, | ||
): AsImageSrcReturnType<Field> => { | ||
if (isImageThumbnailFilled(field)) { |
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.
Side note but we should at some point update the other helpers to use those isFilled()
functions too, great move!
…responsive views
@lihbr The PR has been updated per your review. Could you take a look at the two remaining comments? (Excuse the messy commit log. We'll squash this one. I was having trouble getting AVA 4 working and ended up reverting to AVA 3 instead… :/) |
No worries ^^ Happens to me everyday~ Looking sharp! Let's just trim down the responsive sizes to the list of 5 and we're good :) |
Types of changes
Description
This PR adds the following image helpers:
asImageSrc
: Converts an Image field to an image URL with optional image transformations (via Imgix).asImageWidthSrcSet
: Converts an Image field to a width-basedsrcset
string.asImagePixelDensitySrcSet
: Converts an Image field to a pixel-density-basedsrcset
string.For more background on the need for and implementation of these helpers, see #37.
Checklist:
🐮