问题
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