-
Notifications
You must be signed in to change notification settings - Fork 25
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
Responsive Image #1212
Responsive Image #1212
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1212 +/- ##
========================================
Coverage 90.00% 90.00%
========================================
Files 1 1
Lines 10 10
Branches 2 2
========================================
Hits 9 9
Misses 1 1 Continue to review full report at Codecov.
|
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.
🌴
Do we need to wait for image processing to finish, or can we rely on fallback of image source?
const [error, setError] = useState(false) | ||
|
||
// Fallback to the raw `url` if manually disable or responsive image is failed to load | ||
if (disabled || error) { |
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.
Nice!
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.
Go. 🌦
media="(min-width: 768px)" | ||
srcSet=${toSizedImageURL({ url: src, size: '1080w', ext: 'webp' })} | ||
onerror="this.srcset='${src}'" | ||
/> |
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.
Cool. Have not used <source>
before.
` | ||
} | ||
|
||
$imgs.forEach(($img) => $img.addEventListener('error', onError)) |
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.
wow.
<UserProfile.Cover>
,<Avatar>
,<ArticleDetail.Content>
, etc.<Img>
componentrelated issue: thematters/matters-server#1128