【问题标题】:amp-html Srcset cannot have both width and dpr sourcesamp-html Srcset 不能同时具有宽度和 dpr 来源
【发布时间】:2016-12-06 15:17:08
【问题描述】:

认为 amp-html 可能存在错误。此代码在两个实例上都生成此错误, Srcset cannot have both width and dpr sources

由 AMP ⚡ HTML 提供支持 – 版本 1480633190770

<amp-img srcset="
  /assets/projects/a/600/b-600.jpg 600w,
  /assets/projects/a/960/b-960.jpg 960w,
  /assets/projects/a/1280/b-1280.jpg 1280w"
  layout="fixed"
  src="/assets/projects/a/b.jpg"
  width="266.66666666666663"
  height="150"></amp-img>

【问题讨论】:

    标签: amp-html srcset


    【解决方案1】:

    我发现了这个related issue,正如@dvoytenko 所说,这是一个已经通过在srcset URL 中使用逗号修复的错误。

    您可能还想检查Match commas in the URLs for srcset 中的给定修复并查看here 的完整更改。

    除此之外,这个GitHub post - Validator Roll-Up 有这个示例代码,可能也有帮助:

    // Srcset cannot have both width and dpr sources
    +    if (hasWidth && hasDpr) {
    +      this.is_successful_ = false;
    +      return;
    +    }
    

    【讨论】:

      猜你喜欢
      • 2015-08-30
      • 2015-06-03
      • 1970-01-01
      • 2012-12-12
      • 1970-01-01
      • 2015-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多