Skip to content

Instantly share code, notes, and snippets.

@evansims
Last active February 5, 2024 16:52
Show Gist options
  • Save evansims/f23e2f49e3d4be793038 to your computer and use it in GitHub Desktop.
Save evansims/f23e2f49e3d4be793038 to your computer and use it in GitHub Desktop.
Embedding or sharing a image or photo uploaded to Google Drive.
<a href="https://drive.google.com/uc?export=view&id=XXX"><img src="https://drive.google.com/uc?export=view&id=XXX" style="width: 500px; max-width: 100%; height: auto" title="Click for the larger version." /></a>

You'll need to grab the ID of the image. Easiest way on the desktop is to right click the file, dive into the Google Drive subcontext menu and choose View on the Web. Grab the string of characters from there and replace the XXX in the code below with it.

@anderskitson
Copy link

anyone looking to strip the id from a url this worked for me

var url = https://drive.google.com/open?id=yourID
var id = url.field2.split("?")[1].split("id=");
console.log(id[1])

@ideal-dev616
Copy link

Thank you so much @ildarius.
I resolved the image showing problem from google drive.

@LaisGalvao
Copy link

Thank you so much for this!! It's working fine!

@abdurrahman6489
Copy link

I am using google drive list api to get all the images from my drive. I'm getting id, name and webviewlink from the drive list api and sending the list of ids and webview links to my react application. but nothing is working for me. I tried drive image, but still not working for me. Anyone has the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment