简体   繁体   中英

Replace all image urls in blogger posts from blogspot.com to googleusercontent.com

I want to change all image urls of blogger posts from 1(2/3/4).bp.blogspot.com to lh4.googleusercontent.com. Here is the script I used

 var images = document.getElementsByTagName("img"); for(var i=0;i<images.length;i++) { images[i].src = images[i].src.replace(/[0-9]+.bp.blogspot.com/,"lh4.googleusercontent.com"); } 

But it didn't work. Please help!!

I am assuming that you want to make this change to reduce DNS Lookup on your blog.

The reason why this approach is flawed because running the above script will lead to downloading of all the image twice and add an extra DNS lookup (for lh4.googleusercontent.com)

A much better approach would be to manually switch from 1(2/3/4).bp.blogspot.com to any one of the subdomains. The reason for this being that all the domains (aka 1(2/3/4).bp.blogspot.com) are mirrors of each other. Like for example , this image - https://1.bp.blogspot.com/-i2Zz0p3UoX4/VgsPJGm9_fI/AAAAAAAAROA/HoN3rq-s93U/s1600/unnamed.png - can also be accessed via 2.bp.blogspot.com , 3.bp.blogspot.com & 4.bp.blogspot.com . This way you can reduce the DNS lookups from 4 to a single domain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM