1. 三档断点 Hero 横幅(Retina 像素密度)
前端工程师背景
正在重构官网首页,需要在桌面大屏、平板和移动端分别使用不同裁切的横幅图片,并针对 2x 高清屏提供清晰图像。
问题
手动编写多层 media 查询与 1x/2x srcset 容易出错且遗漏兜底标签。
如何使用
在艺术方向源中填入 1280 与 768 断点路径,选择像素密度模式(1x,2x),设置移动端兜底 URL 与 alt 描述,方言选 HTML。
sources: "1280 /img/hero-wide.jpg\n768 /img/hero-mid.jpg"
descriptorMode: "density"
densities: "1x,2x"
fallbackUrl: "/img/hero-mobile.jpg"
altText: "Fresh sourdough loaves on a marble counter"
flavor: "html"
lazyAttrs: true结果
生成包含两组 `<source media="(min-width: ...)">` 和一组兜底 `<img>` 的 HTML 代码,支持高清屏并附带懒加载属性。