【问题标题】:How to include image url If it doesn't have featuredImage blogger?如果没有featuredImage博主,如何包含图片网址?
【发布时间】:2020-11-16 05:58:23
【问题描述】:
<b:with value='data:post.featuredImage.isYoutube ? resizeImage(data:post.featuredImage.youtubeMaxResDefaultUrl, 945, &quot;945:600&quot;): &quot;https://1.bp.blogspot.com/-aR5w9KXuWGU/XhSDNRAVuhI/AAAAAAAAHG8/dLxcaZxSgh0v85JG0mWRMQyEwqMgpL1_gCLcBGAsYHQ/w420-h280-c/no-image.jpg&quot;' var='highRes'>
  <b:with value='data:post.featuredImage ? data:highRes : &quot;https://1.bp.blogspot.com/-aR5w9KXuWGU/XhSDNRAVuhI/AAAAAAAAHG8/dLxcaZxSgh0v85JG0mWRMQyEwqMgpL1_gCLcBGAsYHQ/w420-h280-c/no-image.jpg&quot;' var='isSource'>
  <a expr:href='data:post.url'>
  <b:include data='{image: data:post.featuredImage,
    imageSizes: [512, 640],
    imageRatio: &quot;640:360&quot;,
    sourceSizes: &quot;(min-width: 954px) 842px,
    (min-width: 801px) calc(640vw - 640px), 
    calc(512vw - 512px)&quot;,
    enhancedSourceset: data:isSource}' name='responsiveImage' />
  </a>
  </b:with>
</b:with>

这是我的代码,效果很好,但是当图像丢失时,url 仍然是空的。

【问题讨论】:

    标签: blogger blogger-dynamic-views


    【解决方案1】:

    您可以使用data:post.featuredImage ? data:post.featuredImage : ".../no-image.jpg"

    <b:with value='data:post.featuredImage ? data:post.featuredImage : "https://1.bp.blogspot.com/-aR5w9KXuWGU/XhSDNRAVuhI/AAAAAAAAHG8/dLxcaZxSgh0v85JG0mWRMQyEwqMgpL1_gCLcBGAsYHQ/w420-h280-c/no-image.jpg"' var='postImage'>
    <b:with value='data:postImage.isYoutube ? resizeImage(data:postImage.youtubeMaxResDefaultUrl, 945, "945:600") : data:postImage' var='highRes'>
      <a expr:href='data:post.url'>
      <b:include data='{image: data:postImage,
        imageSizes: [512, 640],
        imageRatio: "640:360",
        sourceSizes: "(min-width: 954px) 842px,
        (min-width: 801px) calc(640vw - 640px), 
        calc(512vw - 512px)",
        enhancedSourceset: data:highRes,
        imageClass: "class names here"}' name='responsiveImage' />
      </a>
      </b:with>
    </b:with>
    

    【讨论】:

    • 可以,但是如何包含&lt;img class="myclass"
    • 在哪里可以获得参考资料?
    • 没有官方参考但是你可以查看this
    猜你喜欢
    • 2020-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-03
    • 1970-01-01
    • 2018-07-21
    • 2018-12-30
    • 2019-01-31
    相关资源
    最近更新 更多