How to resize thumbnail size without using js in blogger?

Viewed 600

This works fine with me
<img expr:src='resizeImage(data:post.firstImageUrl, 250)'/> but my problem is that it doesn't support third party images.

blog.postImageUrl works fine too but the problem is it will render the original size of the image and you can't use resizeImage.

2 Answers

Using on-the-fly image resizing services would be a way forward in this scenario

Google has an undocumented endpoint used for on-the-fly image resizing. As explained in https://czm.io/posts/2013/04/google-image-resizer/, that endpoint is as follows -

Base URL

https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy

Parameters:

  • url: original image URL

  • container: must be “focus”

  • refresh: time (in seconds) to cache it on G’s servers

  • resize_w: width in pixels

  • resize_h: height in pixels You can either specify both

  • resize_* parameters or just one.

For making sure that you only resize external images, you will need to set up a Blogger conditional for testing if the thumbnail exists or not (data:post.thumbnailUrl is always non-existent for external images excluding post containing Youtube videos)

As Google's endpoint is undocumented, we can't be sure about its availability in future (Due to the fact that this is related to Google+ social network which is itself closing down in April 2019). There are multiple alternatives for on-the-fly image resizing services which are both paid (like https://kraken.io/docs/image-resizing, https://www.imgix.com/) and self-hosted (like https://github.com/jimmynicol/image-resizer)

Change firstImageUrl to featuredImage.

Example:

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

It works everytime.

Related