如何在Blogger中替换缩略图URL中的字符串?

时间:2019-02-25 03:59:42

标签: widget blogger

如何将字符串s0-d替换为-w280-h152-p-k-no-nu
在数据标签data:post.featuredImage

示例:

replace('s0-d', '-w280-h152-p-k-no-nu', data:post.featuredImage);

1 个答案:

答案 0 :(得分:1)

v2 Blogger模板中,data:post.featuredImage与Popular Posts小部件相关,我们可以使用预先存在的代码-

<b:with value='data:post.featuredImage.isResizable?resizeImage(data:post.featuredImage, 72, &quot;1:1&quot;):data:post.thumbnail' var='image'>

并修改resizeImage运算符中存在的宽度和比率参数,以满足我们的要求

<b:with value='data:post.featuredImage.isResizable?resizeImage(data:post.featuredImage, 280, &quot;280:152&quot;):data:post.thumbnail' var='image'>

v3 Blogger模板中,直接使用resizeImage运算符就可以实现目标

<img expr:src='resizeImage(data:post.featuredImage, 280,"280:152")'/>

通常data:post.featuredImage中使用的snippetedPostThumbnail数据标签位于b:with b:includable标签内(此标签有多个实例)。在特定的小部件(例如“特色文章”小部件,“博客文章”小部件等)中进行编辑会影响该特定小部件中的所有图像。使用snippetedPostThumbnail运算符将resizeImage b:includable标签的定义中突出显示的<b:includable id='snippetedPostThumbnail'> <div class='snippet-thumbnail'> <b:with value='data:post.featuredImage.isYoutube ? resizeImage(data:post.featuredImage.youtubeMaxResDefaultUrl, 945, &quot;945:600&quot;) : &quot;&quot;' var='highRes'> <b:include data='{image: data:post.featuredImage, imageSizes: [256, 512, 945, 1684], imageRatio: &quot;945:600&quot;, sourceSizes: &quot;(min-width: 954px) 842px, (min-width: 801px) calc(100vw - 112px), calc(100vw - 64px)&quot;, enhancedSourceset: data:highRes}' name='responsiveImage'/> </b:with> </div> </b:includable>部分替换为先前的图像标签,将具有预期的效果

predictions = model.predict(testData)