How do I display images from Google Drive on a website? - html

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?

Example of Embedding a Google Drive Image
Original URL: https://drive.google.com/file/d/0B6wwyazyzml-OGQ3VUo0Z2thdmc/view
You need to copy the ID from the original URL (the characters between the /d/ and /view), and use it in this URL:
https://drive.google.com/uc?export=view&id=0B6wwyazyzml-OGQ3VUo0Z2thdmc
The image below is embedded using this method:
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/uc?export=view&id=0B6wwyazyzml-OGQ3VUo0Z2thdmc">
<br>
<a href="https://drive.google.com/uc?export=download&id=0B6wwyazyzml-OGQ3VUo0Z2thdmc" download>
Download
</a>
</body>
</html>
Thank You https://codepen.io/jackplug/pen/OPmMJB

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?.

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.

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:
http://gdriv.es/myimgs/
https://docs.google.com/folder/d/[folderID]/preview?rm=minimal
https://drive.google.com/folderview?id=[folderID]
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.

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:
Upload your image to google drive.
Share your image from the sharing option.
Copy your sharing link (Sample: https://drive.google.com/file/d/14hz3ySPn-zBd4Tu3NtY1F05LSGdFfWvp/view?usp=sharing)
Copy the id from your link, in the above link, the id is: 14hz3ySPn-zBd4Tu3NtY1F05LSGdFfWvp
Have a look at the below link and replace the ID.
https://drive.google.com/thumbnail?id=1jNWSPr_BOSbm7iIJQTTbl7lXX06NH9_r
After Replace ID: https://drive.google.com/thumbnail?id=14hz3ySPn-zBd4Tu3NtY1F05LSGdFfWvp
Now insert the link to your <img> tag.
And now it should work.

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

From google drive help pages:
To host a webpage with Drive:
Open Drive at drive.google.com and select a file.
Click the Share button at the top of the page.
Click Advanced in the bottom right corner of the sharing box.
Click Change....
Choose On - Public on the web and click Save.
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.
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

Extension of the above-mentioned answer. I wrote a UNIX command so I can easily do it in my workflow.
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
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
P.S. If you copy the command from here. Make sure to copy the Google Drive image URL again. :P
No need to change anything in the Step 2 command as it takes from Clipboard.
Make sure it is copied in right format
E.g.
https://drive.google.com/file/d/XXXX/view?usp=sharing

if you want to embedded Google drive images in your blogger or any sites then just follow the instructions : -
Blogger
upload the image on google drive
click on image and share with public
<img src='https://drive.google.com/uc?export=view&id=1OCx6mUEMbWcwCQbDePA5PeeOh'/>

This method allows you to embed the image at whatever size or resolution you need:
Create a folder in your Google Drive
Make the folder (or image itself) public via the "Share" button
Copy the URL and extract the ID. It should look like
https://drive.google.com/file/d/ID-HERE/view?usp=sharing
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.

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/

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.

<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

Based in different answers I created a tool to help creating the HTML Embed Code or the direct link.
Steps 1: Copy the Google Drive Url.
https://drive.google.com/file/d/18RX_EwpYdZsKU0QobLvNidmhvqJPEhrH/view?usp=sharing
Step 2: Pase the URL in the tool (check screenshot) and click generate link, the result will be like this:
<img src="https://drive.google.com/uc?export=view&id=18RX_EwpYdZsKU0QobLvNidmhvqJPEhrH" width="100%"/>
How to use the tool -> Read the instructions
Link to the tool here -> Embed Google Drive Images

Upload the image at a specic folder at dgrive
Make this image as view foe who is having the link
copy the link, something like: https://drive.google.com/file/d/IMAGE_ID/edit
Take the ide from the link
Use the id with th ebelow link: drive.google.com/uc?export=view&id=IMAGE_ID
This reference if very helpful for fixing html5 images at outlook:
https://www.emailonacid.com/blog/article/email-development/how-to-code-emails-for-outlook-2016/#images

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

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.
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.

As this Spanish blog explains and provides a link convertor.
Upload your image in your google drive.
Share it with anyone on the web.
Copy the sharing link.
Then you can use the converter that ClasicWebTools provides to use it on your web.

<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>

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

i supposed you uploaded your photo in your drive all what you need to do is while you are opening your google drive just open your dev tools in chrome and head to your img tag and copy the link beside the src attribute and use it

Related

Google Drive images in img src=webContentLink?

Can I use images stored in Google Drive to be used in a website by the html,<img src="<webContentLink>" /> ?
Where <webContentLink> is returned after a file is uploaded and is in the format, 'https://drive.google.com/uc?id=<FILEID>&export=download'
I have a small website created for account users only. They can upload files to their google drive folder and this folder has permissions set to share with the accounts of the other users (specific people only). This is an ASP.NET MVC 5 website using the Google API Client Libraries for .NET.
In Chrome and Firefox the images display fine, in IE and Safari they don't show and return a 302 status code. Sometimes if you view the image directly in a new tab and then refresh the web page it shows. It might also show if the folder permission is set to 'anyone with the link', but this isn't ideal.
The documentation (https://developers.google.com/drive/v3/web/manage-downloads) says, 'If you want to allow a user to view a file directly in a web browser instead of through the API, use the webContentLink.' I understood this to be okay to use img src='' to display an image directly without the API, however it then goes on to say, 'You can either redirect a user to this URL, or offer it as a clickable link'.
So can Google please confirm if 'webContentLink' can be used in img src='', or not and why it works in some browsers and not others? I've read many posts on this, some old, some more recent. If it's not to be used in img src I think it should be made clear in the documentation.
Many thanks
Yes, you can definitely use webContentLink as your img src in your HTML page. I tried and this is what I got on my sample HTML page.
<img src = "https://drive.google.com/uc?id=0Bzgk4zncCwI7aDZCSHY4YU0zNUF&export=download">
webContentLink can be obtained using Files.list and place 'files' in the fields parameter.
Displaying an image from Google Drive can be done in 3 steps:
Retrieving your image ID
Right click on your image and select Share.
You'll see a link that you need to copy. You will extract the image's ID from the URL.
Here is what your sharing link should look like:
https://drive.google.com/open?id=YourFileId
Check your sharing settings
Your images will only be visible to people who have access to those files. To allow anyone access to your images, you need to set the sharing setting as Visible with the link.
Display your image
With your sharing settings properly configured and your image file IDs at hand, you can now specify how your images will be displayed using a prescribed format.
https://drive.google.com/thumbnail?id=YourFileID
More details can be found here
when I do this I just get a sign like an nonexistent image.
Why?
I just copy paste this line:
<img src = "https://drive.google.com/uc?id=0Bzgk4zncCwI7aDZCSHY4YU0zNUF&export=download">
JS Fiddle

Display File from Google Drive using docs.google.com/gview Embedded in iFrame

I have a file saved in google drive.
I want to display it on a website embedded in an iframe.
I'm trying to use the google docs viewer, but can't quite get it to work.
<iframe src="https://docs.google.com/gview?url={fileUrl}&embedded=true"></iframe>
If I copy the file to an s3 bucket (or anywhere else other than google drive) and use an external link such as https://s3.../filename.ext for the fileUrl - it works!
But I can't figure out what link to use from Google Drive. The share and edit links don't work.
https://drive.google.com/open?id={fileId} Share Link.
https://docs.google.com/document/d/{fileId}/edit Open/Edit Link.
After a lot of trial and error with a bunch of google drive/docs links, I figured it out.
The trick is using the direct download link. https://drive.google.com/uc?id={fileId}
So your iframe src should look like this:
<iframe src="https://docs.google.com/gview?url=https://drive.google.com/uc?id={fileId}&embedded=true"></iframe>
This works, no reload issue .
https://drive.google.com/file/d/(YOUR_FILE_ID)/preview

Use drive images in html file in google app script project

How to access my google drive images from app script html file so that i can use those images in my img tags something like src= "https/googledrive/folderID/imagename.png"
I have not able to find any relevant answer.Please help!
you cant. ok you can but only for a few more months as google has deprecated "google drive hosting" (google that if you still want to use it)
instead you can use another free google hosting like a google site. put images in a file cabinet page and make the page public. like this image:
https://sites.google.com/a/plusfortrello.com/images/img/bubble-sprite.png which is the cabinet site plus plus the image name appended.
sites images have disadvantages like lack of caching and slow GET. you can greatly speed it up using a (paid) Google Cloud Storage bucket mentioned in this blog post of mine: http://zigmandel.blogspot.com/2015/09/how-i-crowd-translated-my-product-tour.html

opening html from google drive

I have made a page in html5 with css3. It works fine on local (I dont use any server, just doubleclick in the index to open it).
I want to put it in google drive. I have load all the documents needed, but when I try to open the html, I can only see the text (I mean, it is not being executing, I can see just the source code).
Any suggestion?
Not available any more, https://support.google.com/drive/answer/2881970?hl=en
Host web pages with Google Drive
Note: This feature will not be available after August 31, 2016.
I highly recommend https://www.heroku.com/ and https://www.netlify.com/
EDIT: As of August 2016 Google Drive can no longer be used to host static web pages, so this solution no longer works.
Create a new folder in Drive and share it as "Public on the web."
Upload your content files to this folder.
Right click on your folder and click on Details.
Copy Hosting URL and paste it on your browser.(e.g. https://googledrive.com/host/0B716ywBKT84AcHZfMWgtNk5aeXM)
It will launch index.html if it exist in your folder other wise list all files in your folder.
I don't think it is necessary to "host" the content using the way from the accepted answer. It is too complicated for a normal user with limited developing skills.
Google actually has provided hosting feature without using Drive SDK/API, what you need is just few clicks. Check this out:
http://support.google.com/drive/bin/answer.py?hl=en&answer=2881970
It is the same to the answer of user1557669. However, in step 4, the URL is not correct, it is like:
https://drive.google.com/#folders/...
To get the correct host URL. Right click on the html file (you have to finish 1-3 steps first and put the html in the public shared folder), and select "Details" from the context menu. You will find the hosting URL right close to the bottom of the details panel. It should look like:
https://googledrive.com/host/.../abc.html
Then you can share the link to anyone. Happy sharing.
Now you can use
https://sites.google.com
Build internal project hubs, team sites, public-facing websites, and more—all without designer, programmer, or IT help. With the new Google Sites, building websites is easy. Just drag content where you need it.
While drive allows you to edit plain text and HTML files I don't believe they allow the HTML to actually be displayed. I don't think they want people hosting websites from their drive space.
A lot of the solutions offered here do not seem to work anymore. I'm currently on a chromebook and wanted to view an HTML5 banner. This seems impossible now through Google Drive or other apps (as mentioned in previous comments).
The method I ended up using to view the HTML5 was the following:
Open Google Adwords (create a free account if you dont have one)
Click on Ads in the top panel
Click on "+AD" and choose image ad
Choose "upload an ad"
Drag and drop your zip file into the area
Click on Preview
Voila, you will see your HTML5 banners in their full beauty
There may well an easier way, but this way is pretty good too. Hope it helps and worked well for me.
Create a new folder in Drive and share it as "Public on the web."
Upload your HTML, JS & CSS files to this folder.
Open the HTML file & you will see "Preview" button in the toolbar.
Share the URL that looks like www.googledrive.com/host/... from the preview window and anyone can view your web page.
Found method to see your own html file (from here (scroll down to answer from prac): https://productforums.google.com/forum/#!topic/drive/YY_fou2vo0A)
-- use Get Link to get URL with id=... substring
-- put uc instead of open in URL

Displaying files (e.g. images) stored in Google Drive on a website

I was wondering if its possible to access/display files like images which are stored in Google Drive on a public website.
A workaround is to get the fileId with Google Drive SDK API and then using this Url:
https://drive.google.com/uc?export=view&id={fileId}
That will be a permanent link to your file in Google Drive (image or anything else).
Note: this link seems to be subject to quotas. So not ideal for public/massive sharing.
Go to your Google Drive.
Right-click on the image file.
Select Get link.
Open the General access drop-down menu.
Select Anyone with the link to publish your image.
Click Copy link > Done.
You will get a URL like the following:
https://drive.google.com/file/d/1wMgCWAsqlw0nXcMhCldTbwSznMdXUmBT/view?usp=share_link
You can see your file ID in bold. Put the file ID in the following simple view link:
https://drive.google.com/uc?id=FILE ID
Result:
https://drive.google.com/uc?id=1wMgCWAsqlw0nXcMhCldTbwSznMdXUmBT
You can take the same steps for other file types: MP3, PDF, etc.
UPDATE: As was announced, Google deprecated this feature in Aug 2016. Here's the final update from Google with alternatives.
Yes, it's possible. Provided that you put your files in a public folder, you can get any file in a folder by this URL:
https://googledrive.com/host/<folderID>/<filename>
here is how from # https://productforums.google.com/forum/#!topic/drive/yU_yF9SI_z0/discussion
1- upload ur image
2- right click and chose "get sharable link"
3- copy the link which should look like
https://drive.google.com/open?id=xxxxxxx
4-change the open? to uc? and use it like
<img src="https://drive.google.com/uc?id=xxxxx">
EDIT : As of 2020, THIS is working. Most previous answers are outdated.
Easy Solution
All you have to do is open your file:
Then, go into your web inspector (for Chrome, Cmd-Shift-I or Ctrl-Shift-I depending on your OS) and get the link. Paste that link into your browser and it will redirect to another link. Copy the new URL. Done!
What's the redirect for?
It seems that if you use the first link, it can only be accessed when signed in to your Google account. Not very helpful for other people. The second, redirected link, however, does not need you to be signed in. That's the rationale behind it.
I deleted the original file shown in the images, but I have another working example here.
I've actually checked back on my example link that I posted in my edit about a week ago, but it no longer seems to be working. It looks like these links only work temporarily, so don't use them for any kind of production environment.
Working solution for Workspace (G suite) users in Nov 2022
Some embed codes do not show the img unless the viewer is logged into gmail, the following works like a regular image on your webhost:
Share item publicly (make sure it says ''Anyone on the internet with this link can view): either the image itself (or the folder where the image resides) then copy the link the following way
Take the ID of the file and insert here:
<img src="https://lh3.googleusercontent.com/d/[ID_OF_THE_FILE]">
Result (if you see the dog below it means the solution still works):
Localmachine
Won't display on MAMP/WAMP type of localhost environments, but does display on webpages.
UPDATE: As was announced, Google deprecated this feature in Aug 2016. Here's the final update from Google with alternatives.
As per April 2013 and using Chrome/webkit, the following worked for me:
1 Make a folder called e.g. "public"
2 Select that folder, right click and Share > Share. Click. Select "Anyone can access"
3 Drag and Drop a file into the folder, and let it upload.
4 Right click on the file and select Details. One of the lines in the Details-Fieldset reads "Hosting". Underneath it is an url:
https://googledrive.com/...
Drag and Drop that url into a new tab. Copy and paste the url and share or embed it anywhere you like.
One limitation is that as far as HTTP goes, only secure HTTP access seems to be possible.
Update:
Another limitation is that files which Google drive can open, won't be accessible that way.
That is, clicking on "Details" won't show an Google-drive url.
To overcome this:
right click on the file in question and select "Open with>Manage apps":
Untick the file-associated apps here
Optional: Reload Google Drive
Right click on the file and select "Details"
Proceed as in step #4
Note: An alternative to the procedure above, is uploading the file with an extension that Google Drive cannot open/is not associated.
If you want to view the file in the browser, it's also possible using a similar method to the one provided by rufo and Torxed:
https://drive.google.com/uc?export=view&id={fileId}
Specifically for G-Suite users
.
As reported in point 3 here, you can use this URL for hosting image
https://drive.google.com/a/domain.com/thumbnail?id=imageID
with following replacements
domain: replace with your company's GSuite domain like pikachu
imageID: replace with the image id / file id
The prerequisite here is that image should have been shared via drive to target audience (either with each person individually or maybe across the org)
If you face problems with size of rendered image, use following options as mentioned here
https://drive.google.com/a/domain.com/thumbnail?id=imageID&sz=w{width}-h{height}
with following replacements (in addition to domain and imageID replacement)
{width}: write the width in pixels (without braces) like 300
{height}: write the height in pixels (without braces) like 200
Per this blog post, a currently working solution is:
<img src=”https://drive.google.com/uc?id=[imageIdGoesHere]" />
Test here
https://drive.google.com/uc?id=1m-uOoFzHn4oUGlEsDSEfPBbJ2QhBJzlM
This is verified to work as of 26th of April, 2021. No shared folder or login is required. But a publicly shared file is.
I think it is possible but only for a short time
What you have to do is set the Access Control List of the file to Public Read-Only (or Public Read/Write). You can do that programmatically using the Google Document List API, or manually through the "Share" button on the Drive image viewer.
Then you can get the URL to the image programmatically by either using the Google Document List API or using the Google Drive API (i.e. file.getDownloadUrl() in Java). You can also easily get a link to the image manually by right clicking on the image in the Google Drive default image viewer.
The problem is that this link has a limited time to live, so it will work for a little while and then stop working.
Basically the URL of the image file stored in Drive should be accessible without any authentication once it has been set shared publicly but that URL is going to change at some point. We might find a solution to this in the future like providing a permanent URL that will redirect to these changing URL but no promises...
From google drive help pages:
To host a webpage with Drive:
Open Drive at drive.google.com and select a file.
Click the Share button at the top of the page.
Click Advanced in the bottom right corner of the sharing box.
Click Change....
Choose On - Public on the web and click Save.
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.
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.
This is the only direct link format without redirection (then a Permalink) and only applies to files directly visible on Google Drive (e.g. images and documents).
It is not affected by the download limit and you can use it to display images on a website.
For example the sharing link:
https://drive.google.com/file/d/FILE_ID/view?usp=sharing
becomes:
https://lh3.googleusercontent.com/d/FILE_ID
lh4, lh5 and lh6 also work.
Some of the previous users were close, but they were missing a step here or there.
Here is a video that shows all of the steps.
(Edit 2-Dec-14 The Below information is incorrect when it comes to the new Google Drive. For the New Google Drive follow these instructions.
There are two options you can use,
option 1 you can click the cog on the top right and revert to the old google drive, IF you revert, use the instructions after "End Edit)"
.
Option 2 or you can follow the work around I found. If I find a better way than this I will update it, but here is what I have found that works.
The full link will look like this "https://googledrive.com/host/(folder id)
Part one of your link that you need is "https://googledrive.com/host/" for the second half you will need to navigate to the file you would like to share.
Once you are in the folder with the file you would like to share, look at the link above
(Example 1 https://drive.google.com/drive/u/0/#folders/0B3UALYkiLexYSXZlcldoU2NpYXM )
(Example 2 https://drive.google.com/drive/u/0/#folders/0B3UALYkiLexYSXZlcldoU2NpYXM/0B3UALYkiLexYRkNnOVhsUVozRU0)
In both of these above examples, the "Folder ID" you need for sharing is the last group of letters and numbers after the "/" so in example one, it is "0B3UALYkiLexYSXZlcldoU2NpYXM" in example two it is "0B3UALYkiLexYRkNnOVhsUVozRU0"
In the examples I used, example 1 was a folder on my drive, and example 2 was a folder inside that first one, that is why it has the entire first link before the second.
We only need the section after the "/" furthest to the right.
So now that you have your "Folder ID", take the above formula "https://googledrive.com/host/(folder id)"
Example 1 https://googledrive.com/host/0B3UALYkiLexYSXZlcldoU2NpYXM
Example 2 https://googledrive.com/host/0B3UALYkiLexYRkNnOVhsUVozRU0
Great, now that you have this link, open it in a new page. It will direct you to the shared folder. Once there you can either right click on any file and select "Copy link address" or you can click any file in that folder and it will take you to the hosted image, the URL at the top of the page is the hosting URL.
That is the how you do it. It is quite annoying, and personally it seems a whole lot easier to just revert to the old google drive.
I will try to make a new tutorial video ASAP
Let me know if this does not work for you and what problem you are experiencing.
End Edit)
https://www.youtube.com/watch?v=QmN22LMPdDk&feature=youtu.be
Or you can just follow the written ones below.
These pictures go with the ones listed in the steps.
https://googledrive.com/host/0B3UALYkiLexYSXZlcldoU2NpYXM/
Create a Folder on your Google Drive that you would like to use for sharing images.
Select that folder and go to the sharing options. Change the "Who has access" options from "Specific People" to "Public on the web"
All images placed in folder will have a hosting link on them shown in Step 4
(Images : Change Folder Option.png, Change folder option 2.png, and Change folder option 3.png)
place an image in that folder.
select the image you would like to share and look at the details section (usually on right hand side) for a section labeled "Hosting" you should find a link that starts with
"googledrive.com/host/(random numbers and digits that are the ID for that folder)/(file name)"
Use that link to share your images. You can use that link to embed them into other websites.
(Images: Change folder option 4.png and Change folder option share.png)
Vetea, if you take the link from picture URL, it does not work, but if you take it from the field "Direct Link" it should work. I have used and tested it in multiple occasions.
A very useful api/url I found is:
imageId -> the file ID
width, the desired width (cannot be greater than image resolution width), must be integer for it to work
height, the desired height (cannot be greater than image resolution height), must be integer for it to work
https://drive.google.com/thumbnail?id=${imageId}&sz=w${width}-h${height}
Note: the api/url will keep the aspect ratio so it will stop at whichever dimension is met first
There is a filetype option in the Google Drive API. You could, maybe, check if that resolves to a valid image. I'd look at an option where if the filetype gives me an invalid image, then get a new direct URL for the file. I haven't figured out exactly how to do this though, but maybe that's a path to try.
You can do it directly from Drive & Gmail. Here's how:
1.Upload an image to Google drive and set permissions for viewing (can be public OR anyone w/ link)
Go to Gmail>Compose. Select the + next to attachment icon.
Select drive icon (triangle shape)
Navigate to your image and right-click copy image url
Paste into web browser or embed on webpages as needed.
For images, open an image in google viewer. i.e.
Method 1
https://docs.google.com/file/d/0Bz7qe_olclTwWDNJRDRmb1pJamM/edit
then view source> find word "texmex-thumb" and aside it there will be link.
1.Change the settings of your picture to public.
2.Get its shareable link.
3.Go to this website and generate a direct download link.
Worked for me!
You can follow below steps to embed the files you want to your website.
Find the PDF file in Google Drive
Preview the PDF file in Google Drive
Pop-out the Google Drive preview
Use the More actions menu and choose Embed item
Copy code provided
Edit Google Sites page where you want to embed
Open the HTML Editor
Paste the HTML embed code provided by the Google Drive preview
Use the Update button and Save the page
References: https://www.steegle.com/websites/google-sites-howtos/embed-drive-pdf
Solution provided by Niutech worked for me i.e.
http://googledrive.com/host/<folderID>/<filename>
But there are 2 outstanding issues
You cannot have 2 files with the same name in the same folder in the drive else this link won't work.
It is not yet clear but Google seems to be planning to deprecate image hosting via drive. please see the link below.
https://support.google.com/richmedia/answer/6098968?hl=en
Function title: goobox
tags: image hosting, regex, URL, google drive, dropbox, advanced
return: string, Returns a string URL that can be used directly as the source of an image.
when you host an image on google drive or dropbox you can't use the direct URL of your file to be an image source.
you need to make changes to this URL to use it directly as an image source.
goobox() will take the URL of your image file, and change it to be used directly as an image source.
Important: you need to check your files' permissions first, and whether it's public.
live example: https://ybmex.csb.app/
cconst goobox = (url)=>{
let dropbox_regex = /(http(s)*:\/\/)*(www\.)*(dropbox.com)/;
let drive_regex =/(http(s)*:\/\/)*(www\.)*(drive.google.com\/file\/d\/)/;
if(url.match(dropbox_regex)){
return url.replace(/(http(s)*:\/\/)*(www\.)*/, "https://dl.");
}
if(url.match(drive_regex)){
return `https://drive.google.com/uc?id=${url.replace(drive_regex, "").match(/[\w]*\//)[0].replace(/\//,"")}`;
}
return console.error('Wrong URL, not a vlid drobox or google drive url');
}
let url = 'https://drive.google.com/file/d/1PiCWHIwyQWrn4YxatPZDkB8EfegRIkIV/view'
goobox(URL); // https://drive.google.com/uc?id=1PiCWHIwyQWrn4YxatPZDkB8EfegRIkIV
Con can disable javascript in your browser open the image file and in the view page source or right click on the image, you will see the image link. ( check share preference before )
However this answer is simple, infact very simple and yea many have mentioned it that simply put the id of image into the following link https://drive.google.com/uc?export=view&id={fileId}
But however easy that is, I made a script to run in the console.
Feed in an array of complete sharable links from google drive and get them converted into the above link. Then they can be simply used as static addresses.
array = ['https://drive.google.com/open?id=0B8kNn6zsgGEtUE5FaGNtcEthNWc','https://drive.google.com/open?id=0B8kNn6zsgGEtM2traVppYkhsV2s','https://drive.google.com/open?id=0B8kNn6zsgGEtNHgzT2x0MThJUlE']
function separateDriveImageId(arr) {
for (n=0;n<arr.length;n++){
str = arr[n]
for(i=0;i<str.length;i++){
if( str.charAt(i)== '=' ){
var num = i+1;
var extrctdStrng = str.substr(num)
}
}
console.log('https://drive.google.com/uc?export=view&id='+extrctdStrng)
window.open('https://drive.google.com/uc?export=view&id='+extrctdStrng,'_blank')
}
}
separateDriveImageId(array)