161

A client of mine has uploaded some photos to their Google Drive and would like me to display their photos on their company website. I reviewed the documentation for displaying Google Drive content on a web page, but it appears that this is simply the instructions for displaying the contents on a web page, which it already does.

My question is, how do I display the contents directly on the client's web page?

2

21 Answers 21

196

Example of Embedding a Google Drive Image

Original URL:

https://lh3.googleusercontent.com/d/0B6wwyazyzml-OGQ3VUo0Z2thdmc=w1000?authuser=1/view

Get the Id from the url(followed by the /d/)

https://drive.google.com/thumbnail?id=0B6wwyazyzml-OGQ3VUo0Z2thdmc&sz=w1000

The image below is embedded using this method:

HTML tag as used above:

<img src="https://drive.google.com/thumbnail?id=0B6wwyazyzml-OGQ3VUo0Z2thdmc&sz=w1000">

Photo by Paula Borowska.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Google Drive</title>
</head>
<body>
     <img src="https://drive.google.com/thumbnail?id=0B6wwyazyzml-OGQ3VUo0Z2thdmc&sz=w1000" alt="Page Image">
    <br>
</body>
</html>

Updated on: Jan/2024

9
  • 1
    Aathi, It does not work for me. Even in codepen if I use my drive link, It does not display the image. Is there any setting that we need to provide in the drive for the file?
    – Aakriti.G
    Mar 8, 2019 at 11:13
  • 2
    This works really well. Make sure its a public folder in gDrive and get the shareable link. I am using a spreadsheet where I paste the gDrive generated shareable link into a cell, then use this formula to adapt it to the purposes described herein: Replace([Img gDrive URL],1,33,"drive.google.com/uc?export=view&id=")
    – jöhg
    Jun 1, 2019 at 17:14
  • 1
    Perfect :+1: worked for me! Also needed to work out how to add custom HTML to gmail signature, but managed it all in the end and this works like a charm, thank you!
    – 4uroraskye
    Dec 17, 2019 at 18:30
  • 5
    I like that you give a demo using a real link. If we can see it, it means it's still working :D
    – Hp93
    Feb 20, 2023 at 20:26
  • 2
    Since January 11th or so, this solution is not working, there's a Google Issue Tracker for this: issuetracker.google.com/issues/319531488, maybe they resolve it, maybe not.
    – ArianJM
    Jan 16 at 9:32
121

Use the 'Get Link' option in Google Drive to get the URL.

Use <img> tag in HTML and paste the link in there.

Change Open? in the URL to uc?.

9
  • 5
    Brilliant, thank you. This has been killing me all day - where did you learn this little gem for a "trick" (uc) and why the heck isn't more widely known. Now to get back to making awesomeness with Fusion Tables.
    – MrGreggles
    Jul 2, 2017 at 10:19
  • 1
    AMAZING! Working in 2017!
    – rainabba
    Aug 29, 2017 at 19:21
  • Hmmm, the usual incantation is uc?export=view&id=..., but seems the export=view is the default! (export=download to trigger the save dialog can come handy too)
    – Chema
    Sep 19, 2017 at 0:46
  • 28
    Not for me; my links are of the type https://drive.google.com/file/d/XXXX/view?usp=sharing
    – RJVB
    May 13, 2019 at 10:01
  • 9
    you can use the link provided in @quitiweb's answer: <img src="drive.google.com/uc?export=view&id=XXX"> and replace the XXX with the ID that's in the URL you get when you go to 'Get Link' :^)
    – Lewis
    Jun 14, 2021 at 10:51
76

I have found a way to do it without using external sites.

<img src="https://drive.google.com/uc?export=view&id=XXX">

https://gist.github.com/evansims/f23e2f49e3d4be793038

<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: Click on “Open in new window” and get the ID from the URL.

Click on “Open in new window”

8
  • 3
    Is there a way to scrape that id automatically?
    – mando222
    Mar 15, 2017 at 15:15
  • I haven't found a way to do it, I'm afraid
    – Quitiweb
    Apr 4, 2017 at 12:11
  • use regex to extract maybe
    – Vaulstein
    Jun 28, 2017 at 10:44
  • 1
    Yup (Sept 2019)
    – user
    Sep 14, 2019 at 22:49
  • A cookie associated with a cross-site resource at google.com was set without the SameSite attribute. Oct 3, 2019 at 9:17
18

If you have some image files, just upload them to a public folder on your Google Drive, copy its folder ID from the address bar (e.g. 0B0Gi4v5omoZUVXhCT2kta1l0ZG8) and paste it into a form at GDrives to choose your own alias (e.g. myimgs) - and voila! You can access the images one by one using e.g. http://gdriv.es/myimgs/myimage.jpg.

If you want to embed a whole folder on your website (in a frame), you can use one of the following URLs, replacing [folderID] with your own ID:

If you prefer to get the file list in XML or JSON, you can use YQL.

Note: You can use Google + Photos to host and embed your images as well.

5
  • 1
    Folder ids are more than 28 characters, which is how long GDrives is expecting the id to be. It works for files, but it seems to be broken with folders now. Jul 11, 2015 at 21:27
  • Doesn't work for me for photos either due to the character limit.
    – dshgna
    Nov 25, 2015 at 7:25
  • 5
    GDrives uses Google Drive Hosting, which will be discontinued on August 31, 2016.
    – browly
    Aug 22, 2016 at 23:05
  • 4
    griv.es doesn't seem relevant anymore
    – jöhg
    Jun 1, 2019 at 16:54
  • Exactly: gdriv.es is totally irrelevant now. I couldn't access my public images through my embedded code on my homepage on sites.google.com.
    – Sae1962
    Sep 20, 2021 at 12:21
14

I have the same problem right now but this article helps me. Updates for the year 2020!

I got the solution from this article:
https://dev.to/imamcu07/embed-or-display-image-to-html-page-from-google-drive-3ign

These are the steps from the article:

  1. Upload your image to Google drive.

  2. Share your image from the sharing option.

  3. Copy your sharing link (Sample: https://drive.google.com/file/d/14hz3ySPn-zBd4Tu3NtY1F05LSGdFfWvp/view?usp=sharing)

  4. Copy the id from your link, in the above link, the id is: 14hz3ySPn-zBd4Tu3NtY1F05LSGdFfWvp

  5. Have a look at this link and replace the ID: https://drive.google.com/thumbnail?id=1jNWSPr_BOSbm7iIJQTTbl7lXX06NH9_r

    After the ID is replaced: https://drive.google.com/thumbnail?id=14hz3ySPn-zBd4Tu3NtY1F05LSGdFfWvp

  6. Now insert the link to your <img> tag.

2
  • 1
    Unfortunately this method only gives you a small 200px wide version of your image (a thumbnail). But if you visit the /thumbnail... URL, you'll be redirected to a new URL that has a number at the end which you can modify to get any size image you want. Amazing!
    – Simon E.
    Jun 8, 2021 at 3:41
  • This works great for email html signatures!
    – RK1
    Oct 27, 2021 at 18:05
11

Update 18/02/2017 Google had depreciated free hosting feature on Google drive and now you cannot host your static website on Google drive for free.

But if you want to host your JavaScript and CSS and Images file on Google drive then you can still do so. You just need to obtain the permalink of the file. following updated tutorial (2017).

http://www.bloggerseolab.com/2017/02/host-images-javascript-and-css-on-google-drive.html

4
  • This is the updated answer and most relevant answer! @fmz
    – C.Colden
    Aug 15, 2017 at 10:49
  • Link is no longer active.
    – eskimwier
    Jan 16, 2019 at 18:49
  • 2
    @eskimwier you can check this alternative link Sep 2, 2019 at 13:23
  • Well, dead-link is one of the reason why Stack Overflow really discourage link-only answer.
    – bayuah
    Aug 15, 2022 at 5:05
10

From google drive help pages:

To host a webpage with Drive:

  1. Open Drive at drive.google.com and select a file.
  2. Click the Share button at the top of the page.
  3. Click Advanced in the bottom right corner of the sharing box.
  4. Click Change....
  5. Choose On - Public on the web and click Save.
  6. Before closing the sharing box, copy the document ID from the URL in the field below "Link to share". The document ID is a string of uppercase and lowercase letters and numbers between slashes in the URL.
  7. Share the URL that looks like "www.googledrive.com/host/[doc id] where [doc id] is replaced by the document ID you copied in step 6.

Anyone can now view your webpage.

If you want to see your image in a website embed the link to pic in your html as usually:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Example image from Google Drive</title>
    </head>
    <body>
        <h1>Example image from Google Drive</h1>

        <img src="https://www.googledrive.com/host/[doc id]" alt="whatever">

    </body>
</html>

Note:

Beginning August 31st, 2015, web hosting in Google Drive for users and developers will be deprecated. You can continue to use this feature for a period of one year until August 31st, 2016, when we will discontinue serving content via googledrive.com/host/[doc id]. More info

2
10

Extension of the above-mentioned answer. I wrote a UNIX command so I can easily do it in my workflow.

  1. Copy the Google Drive photos URL which needs to be converted. E.g.

    Copy Google Drive Image URL

    https://drive.google.com/file/d/XXXX/view?usp=sharing
    
  2. Open the terminal and execute this command.

    Command:

    echo https://drive.google.com/uc\?export\=view\&id\=`echo $(pbpaste) | cut -d '/' -f 6`
    

    Output:

    https://drive.google.com/uc?export=view&id=XXXX
    

If you copy the command from here. Make sure to copy the Google Drive image URL again.

No need to change anything in the Step 2 command as it takes from clipboard. Make sure it is copied in right format. For example:

https://drive.google.com/file/d/XXXX/view?usp=sharing
1
  • i am using in php so i used explode('d/',url); it works grate thank you Jun 25, 2020 at 12:34
9

This method allows you to embed the image at whatever size or resolution you need:

  1. Create a folder in your Google Drive

  2. Make the folder (or image itself) public via the "Share" button

  3. Copy the URL and extract the ID. It should look like
    https://drive.google.com/file/d/ID-HERE/view?usp=sharing

  4. Use something like this as your image src:
    https://drive.google.com/thumbnail?id=${imageId}&sz=w${width || 200}-h${height || 200}

    Example:
    https://drive.google.com/thumbnail?id=ID-HERE&sz=w200-h200

You can modify the numbers after w and h to get whatever size you need. The image will be shrunk to fit inside those dimensions.

3
  • Great tip! I love how this option allows you to scale the image to whatever size you need.
    – Simon E.
    Jun 8, 2021 at 3:52
  • Also make sure you've made the image public with "Anyone with link" Jul 6, 2022 at 1:38
  • &sz=w${width || 200}-h${height || 200} and &sz=w200-h200 are not working for me
    – Kuhan
    Nov 25, 2022 at 5:38
8

if you want to embedded Google drive images in your blogger or any sites then just follow the instructions : -

Blogger

  1. upload the image on google drive
  2. click on image and share with public
  3. <img src='https://drive.google.com/uc?export=view&amp;id=1OCx6mUEMbWcwCQbDePA5PeeOh'/>
0
5

List View

<iframe src="https://drive.google.com/embeddedfolderview?id=YOURID#list" width="700" height="500" frameborder="0"></iframe>

Grid View

<iframe src="https://drive.google.com/embeddedfolderview?id=YOURID#grid" width="700" height="500" frameborder="0"></iframe>

Read More at: https://thomas.vanhoutte.be/miniblog/embed-add-google-drive-folder-file-website/

1
  • How to increase the size of the images inside the iframe
    – Kuhan
    Mar 23, 2021 at 5:55
5

Google Drive Hosting is now deprecated. It stopped working from August 31, 2016.

hosting on Google Drive - deprecation schedule

I have removed the explanation of how to previously host an image on Google Drive.

1
  • Hosting on Google Drive to be deprecated. See updated answer.
    – Alan Wells
    Sep 23, 2015 at 20:19
4
<img src="https://drive.google.com/uc?export=view&id=Your_Image_ID" alt="">

I use on my wordpress site as storing image files on local host takes up to much space and slows down my site

I use textmate as it is easy to edit multiple URLs at same time using the 'alt/option' button

4

Based in different answers I created a tool to help creating the HTML Embed Code or the direct link.

  1. Copy the Google drive URL.
    https://drive.google.com/file/d/18RX_EwpYdZsKU0QobLvNidmhvqJPEhrH/view?usp=sharing
    
  2. Pass the URL to this tool (check screenshot) and click generate link, the result will be like this:
    <a href="https://drive.google.com/uc?export=view&id=18RX_EwpYdZsKU0QobLvNidmhvqJPEhrH"> <img src="https://drive.google.com/uc?export=view&id=18RX_EwpYdZsKU0QobLvNidmhvqJPEhrH" width="100%"/></a>
    

enter image description here

1
  1. Upload the image at a specic folder at dgrive.

  2. Make this image as view for who is having the link.

  3. copy the link, something like:

    https://drive.google.com/file/d/IMAGE_ID/edit
    
  4. Take the image ID from the link.

  5. Use the image ID with th below link:

    drive.google.com/uc?export=view&id=IMAGE_ID
    

This reference is very helpful for fixing HTML5 images at outlook:

0

I don't know of a better way but you can datamine the page with php. For instance if you go to google and share a folder then go to that folder it will look something like

https://drive.google.com/folderview?id=0B8TT0olkjsdkfji9jekbFF4LWc&usp=sharing

^^^ not a real link

What you are looking for is the individual images inside the source code of this page

then using php get the source code with

<? $f = fopen ("http://www.example.com/f", r);
echo $f;
?>

now $f has the source and you can use other php commands to seperate only the URLS with the images you want. It will take a bit of work but highly doable.

once you have these image links showing the way you want just build them into a div or table structure to display on a gallery maybe even add a greybox element for effect

0

A couple interesting alternatives to publicly hosting an image on Drive (deprecated):

1. Google Photos

If you upload an image to Google Photos instead of Drive it gets a public web link.

This behavior is a little surprising to me, but the link is very long and random, so they are apparently practicing "privacy by obscurity."

2. Google Drawing

If you create an image using the "Google Drawing" program (built into Drive) you can press File > Publish to Web to get a public link.

enter image description here

Note: This could be a solution if you're trying to share an existing image-- paste the image into the editor and crop the canvas to your image (file > Page Setup)-- but it's a little cumbersome. If you need to do some basic image editing, though, or if you're trying create a simple icon/graphic, I think this is nifty.

0
<p><iframe frameborder="0" height="1000px" src="https://drive.google.com/[folder address]/embeddedfolderview?id=[folder id]#grid" width="100%"></iframe></p>

you could easily get the folder id, just right mouse click on the folder, copy the share link and paste some text/Html file there you get the folder id

Example of Embed a Google Drive

<p><iframe frameborder="0" height="1000px" src="https://drive.google.com/a/esn.ac.lk/embeddedfolderview?id=19FWi2HI98Gim6VjZfHT391EBClO8Jxco#grid" width="100%"></iframe></p>
0
import urllib.parse 

def transform_google_drive_link(original_link):
    parsed_url = urllib.parse.urlparse(original_link)
    query_params = urllib.parse.parse_qs(parsed_url.query)
    
    # The file ID should be in the 'd' path component
    file_id = parsed_url.path.split('/')[-2]
    
    # Construct the new URL for embedding the image
    embeddable_url = f"https://drive.google.com/uc?export=view&id={file_id}"
    
    return embeddable_url
0
0

As this Spanish blog explains and provides a link convertor.

  1. Upload your image to your Google drive.
  2. Share it with anyone on the web.
  3. Copy the sharing link.

Then you can use the converter that ClasicWebTools provides to use it on your web.

-2

If the file is in a public folder, you can use Google Drive website hosting.

4
  • Hi Ali, this doesn't address the issue of displaying the images on the client's website. Thanks.
    – forrest
    Mar 25, 2013 at 12:01
  • Hi, it does if you get the URL, and put it in an <img src="... tag. The URL won't change.
    – Ali Afshar
    Mar 25, 2013 at 14:42
  • That is individually though. Correct? There isn't a feed or something that I could do to accomplish this?
    – forrest
    Mar 26, 2013 at 14:58
  • The link is dead now.
    – Wai Ha Lee
    Oct 22, 2021 at 14:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.