responsive-images
它能做什么
这个技能检查网站的图片标记,并在缺少或有误的地方添加或修正 srcset 和 sizes 属性。它面向在不同屏幕上以不同尺寸显示图片的网站构建者。
适用场景
- ✓你请智能体让图片为每种设备加载合适尺寸的时候。
- ✓手机下载大型桌面图片,导致加载感觉很慢的时候。
- ✓你在构建文章卡片、图库或其他以多种宽度显示图片的组件的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/responsive-images/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的网站给手机发送了很大的图片。请帮我设置响应式图片,让每种设备都获得合适的尺寸吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会添加包含多种宽度的 srcset,以及与真实布局相符的 sizes 属性。这样浏览器就能为每个屏幕和像素密度选择最小的合适文件。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Implement responsive images with srcset
Serving a 2000px image to a 400px phone screen wastes bandwidth and slows loading—srcset lets the browser download only the size it needs.
Quick Reference
- Use srcset to provide multiple image sizes
- Use sizes attribute to tell browser which size to download
- Browser selects optimal size based on viewport and DPR
- Can save 50-70% bandwidth on mobile devices
Check
Verify that images use srcset and sizes attributes for responsive delivery.
Fix
Implement responsive images with srcset for different screen sizes and resolutions.
Explain
Explain how responsive images deliver optimized versions based on device capabilities.
Code Review
Inspect image markup and component abstractions for srcset, sizes, and width/height handling. Flag pages that always ship desktop-sized assets to mobile, omit sizes, or generate variants that do not match the actual rendered layout.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/images/responsive-images
常见问题
如果 sizes 写错了会怎样?
这个技能说,错误的 sizes 属性会抵消 srcset 的好处,因为浏览器可能会选中过大的文件。
我需要制作多个图片版本吗?
需要。srcset 需要同一图片的多个尺寸,智能体可以帮忙生成。
这对流量有帮助吗?
这个技能说,它可以为移动设备节省大量流量。
详情
作者的原始描述
Use when reviewing article images, cards, galleries, or any component rendered at multiple sizes across breakpoints. Check both the markup and the CSS layout because an incorrect `sizes` attribute can negate a perfectly good `srcset`.
热度
- GitHub 星标
- 75k
- 排名
- #2997
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。