Saturday 20 January 2024

Open Live Writer

Further to my previous post.  Below is an enhancement to the HTML/JavaScript which removed the blurry image problem.

It works for me!

 

`<script type="text/javascript">
// Get all the img elements
var imgs = document.getElementsByTagName('img');

// Define constants
const srcA = 'drive.google.com/uc?id=';
const srcB = 'drive.usercontent.google.com/download?id=';
const srcBRemove = '&authuser=0';

const targ = 'lh3.googleusercontent.com/d/';

function reWriteIMG() {
// Loop through the img elements and replace the links accordingly
for (var I = 0; I < imgs.length; I++) {
if (imgs[I].src.indexOf(srcA) > -1) {
// Replace the link format for srcA
imgs[I].src = 'https://' + targ + imgs[I].src.split(srcA)[1];
} else if (imgs[I].src.indexOf(srcB) > -1) {
// Replace the link format for srcB
var tmp = imgs[I].src.replace(srcBRemove, '');
imgs[I].src = 'https://' + targ + tmp.split(srcB)[1];
}
}
}

// Call the function immediately during page load
window.onload = reWriteIMG;
< /script>`

4 comments :

Brian and Diana on NB Harnser said...

This one didn't work for me, the older version did that you linked to

Tom and Jan said...

Brian have you tried logging in and out of Blogger. My photos initially didn't appear. I'm not sure if it was the logging in and out of Blogger or just waiting.

Jenny said...

Hi Tom.
This did not work for me. I wondered whether the little dot at the very beginning of the script was the problem.

Robin

Tom and Jan said...

Jenny

Dot or single quote?