How to display higher-res thumbnails on Blogger

ε祈祈猫儿з 提交于 2020-01-01 19:17:10

问题


All this time I've been using <img expr:src='data:post.thumbnailUrl'/> to display thumbnails on my homepage, which outputs a 72x72 square image originally made for mobile browsing. I then use jquery to scale the image from 72-c to s300. I wonder if there's a different approach to get a thumbnail without using js.

The new set of templates released by Blogger can output a thumbnail size available in 32, 64, 128 and 256 px using data:post.featuredImage. How can I apply this to custom templates?


回答1:


Utilize the resizeImage operator to change image size without JavaScript. The code will look like -

<img expr:src='resizeImage(data:post.thumbnailUrl, 1600)'/> 

resizeImage(imageUrl, newSize, optionalRatio)

The resizeImage operator takes 3 parameters:

imageUrl - The original URL of the resizable image.
newSize - The new width of the image
(optional) ratio - The integer ratio of width to height for the resized image, e.g. “1:1” or “4:3”

Notes

If the imageUrl parameter is not a resizable image, the resizeImage function will return the original imageUrl.
The ratio must be integer numbers.
If the ratio is provided, the image will be cropped to those exact dimensions.



来源:https://stackoverflow.com/questions/45500573/how-to-display-higher-res-thumbnails-on-blogger

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!