如何包含图片 url 如果没有 featuredImage blogger?
How to include image url If it doesn't have featuredImage blogger?
<b:with value='data:post.featuredImage.isYoutube ? resizeImage(data:post.featuredImage.youtubeMaxResDefaultUrl, 945, "945:600"): "https://1.bp.blogspot.com/-aR5w9KXuWGU/XhSDNRAVuhI/AAAAAAAAHG8/dLxcaZxSgh0v85JG0mWRMQyEwqMgpL1_gCLcBGAsYHQ/w420-h280-c/no-image.jpg"' var='highRes'>
<b:with value='data:post.featuredImage ? data:highRes : "https://1.bp.blogspot.com/-aR5w9KXuWGU/XhSDNRAVuhI/AAAAAAAAHG8/dLxcaZxSgh0v85JG0mWRMQyEwqMgpL1_gCLcBGAsYHQ/w420-h280-c/no-image.jpg"' var='isSource'>
<a expr:href='data:post.url'>
<b:include data='{image: data:post.featuredImage,
imageSizes: [512, 640],
imageRatio: "640:360",
sourceSizes: "(min-width: 954px) 842px,
(min-width: 801px) calc(640vw - 640px),
calc(512vw - 512px)",
enhancedSourceset: data:isSource}' name='responsiveImage' />
</a>
</b:with>
</b:with>
这是我的代码,效果很好,但是当图像丢失时,url 仍然是空的。
您可以使用 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>
<b:with value='data:post.featuredImage.isYoutube ? resizeImage(data:post.featuredImage.youtubeMaxResDefaultUrl, 945, "945:600"): "https://1.bp.blogspot.com/-aR5w9KXuWGU/XhSDNRAVuhI/AAAAAAAAHG8/dLxcaZxSgh0v85JG0mWRMQyEwqMgpL1_gCLcBGAsYHQ/w420-h280-c/no-image.jpg"' var='highRes'>
<b:with value='data:post.featuredImage ? data:highRes : "https://1.bp.blogspot.com/-aR5w9KXuWGU/XhSDNRAVuhI/AAAAAAAAHG8/dLxcaZxSgh0v85JG0mWRMQyEwqMgpL1_gCLcBGAsYHQ/w420-h280-c/no-image.jpg"' var='isSource'>
<a expr:href='data:post.url'>
<b:include data='{image: data:post.featuredImage,
imageSizes: [512, 640],
imageRatio: "640:360",
sourceSizes: "(min-width: 954px) 842px,
(min-width: 801px) calc(640vw - 640px),
calc(512vw - 512px)",
enhancedSourceset: data:isSource}' name='responsiveImage' />
</a>
</b:with>
</b:with>
这是我的代码,效果很好,但是当图像丢失时,url 仍然是空的。
您可以使用 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>