Hosting images on Google Drive

  Markdown Image Hosting

Images can be embedded directly from Google Drive. You need to copy the link from the google drive interface and make some changes to it. You also need to ensure the sharing permission is set to allow the image to be embedded.

Set sharing permissions and copy the sharing link

Find the file you want to embed, right-click and go to Share > Share.

This will bring up the sharing properties.

The default permission is probably Restricted. This needs to be set to Anyone with the link for the embedding to work. Change this option then click on the Copy link button to copy the direct link into your clipboard.

This link will open the image in your browser but won’t embed, you need to alter it a little to get it to work.

Formatting the image URL

The copied URL will look something like this

https://drive.google.com/file/d/1PI_v8a2jPWfPpKvmD_uL6xKKRbZcb7rG/view?usp=sharing

You need to alter this URL by changing the file/d/ part to uc?id= from the middle and removing the /view?usp=sharing from the end. The random character string is the ID for this file and needs to be identical. After this change, you URL can be pasted into the notebook and the image will appear.

Example

Changehttps://drive.google.com/file/d/1PI_v8a2jPWfPpKvmD_uL6xKKRbZcb7rG/view?usp=sharing
Tohttps://drive.google.com/uc?id=1PI_v8a2jPWfPpKvmD_uL6xKKRbZcb7rG

Alternate methods of getting the URL

The manual method above is one method of the URL. There are tools online that can do the work for you, for example this one from labnol.org. Using this, you should be able to paste you sharing link in and copy the direct link out.