Quantcast
Viewing all articles
Browse latest Browse all 39

Answer by Prayag Verma for Blogger, How to Change Thumbnail Size for the 'Random' Posts?

Using Google's on-the-fly image resizing service would be a better approach in this case. As explained by Carlo Zottmann (https://stackoverflow.com/users/333272/carlo-zottmann) in https://czm.io/posts/2013/04/google-image-resizer/, the API 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.

You will need to change the following block of code -

// how to resize this external image ?randompoststhumb = entry.content.$t.match(/\<img.+src\=(?:\"|\')(.+?)(?:\"|\')(?:.+?)\>/)[1];// like using 'resizeImage' function in blogger includable expr:

with -

// how to resize this external image ?randompoststhumb = entry.content.$t.match(/\<img.+src\=(?:\"|\')(.+?)(?:\"|\')(?:.+?)\>/)[1];randompoststhumb = 'https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url='+ randompoststhumb +'&container=focus&resize_w=300&resize_h=300&refresh=2592000';// like using 'resizeImage' function in blogger includable expr:

As we can't use resizeImage operator in this use case, you can also utlize the same API to resize the images uploaded to Blogger as well. You will need to replace -

var randompoststhumb = entry.media$thumbnail.url

with -

var randompoststhumb = entry.media$thumbnail.url.replace("s72-c", "s0").replace("/default.jpg","/hqdefault.jpg");randompoststhumb = 'https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url='+ randompoststhumb +'&container=focus&resize_w=300&resize_h=300&refresh=2592000';

As this is an undocumented API, we can't be sure about its availability in future (Due to the fact that this is related to Google+ social network which is 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) and self-hosted (like https://github.com/jimmynicol/image-resizer)


Viewing all articles
Browse latest Browse all 39

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>