Pages

Saturday, February 4, 2017

Hosting Images in Google Drive

Hosting Images in Google Drive

The simplicity and reliability of Google Drive makes it an ideal place to host content that you post around the web. This is a bit of a problem when trying to host images, however. While you can store images in Drive, you can't directly link to them because Google doesn't give you the full web URL of an image. 


The Problem with hosting images in Google Drive

If you share an image file to "public on the web" or "anyone with the link" this is what you get:
https://drive.google.com/a/sowashventures.com/file/d/1e_t9fHoH8bsQ0hV0s7kw2KO2elRETvCUgw/view?usp=sharing

While this type of link is fine for sending via email, you can't use it to insert an image into a WordPress site, blogger page, or other web publish tool. These services require a direct link to the image - something that ends in .jpg, .png, etc. When I upload files to my wordpress site I am able to get such a link:
http://chrome-lab.com/wp-content/uploads/2015/12/CLabLogo_Logo-02.jpg
This complication is a bit of a bother. I really want to host images in drive. So I started looking for a solution. What I discovered was gdurl.com.

The Solution - GDurl.com


Google Drive URL (gdurl.com) is a free service that generates a permalink URL for any file hosted in Drive. This is particularly helpful for images.
1. Make sure your file is public (it won't work for private files)
2. Copy the public link to the file presented in the sharing box:











3. Visit dgurl.com and past in the link you just copied.
4. Click "create permalink"
5. Copy the permalink to your image and use it in your blog, website, etc.

Why use GDurl? 

I created an intranet for a large school in Ohio using Google Sites. The intranet featured heavy use of icons for navigation. Google Sites makes it tough to manage a large number of graphics for a website. Instead of uploading and inserting them into the Google Sites, we used GDurl to embed the images which were stored in drive.

A Sneaky Feature of Google Drive


To change an image, we used a sneaky feature of Google Drive - the ability to upload a new version of an existing file. Right click on a file and look for "manage versions." Even though you have uploaded a new version of the file, the link stays the same!

You can use this feature to update dozens or hundreds of instances of an image across the web.

A word of Caution

While GDurl is an outstanding resource, I do have one word of caution. GDurl is a free (ad supported) service. The link that is generated uses a GDurl short link. This is fine, as long as GDurl stays open. If they ever close and depreciate their link database, all of your links would be broken.

You can skirt this issue by copying the short GDurl link and pasting it into your browser. It will then redirect to Google Drive permalink. Using this link instead of the GDurl link will ensure that your links stay intact even if GDurl closes.

  • GDurl Link: http://gdurl.com/5Gva
  • Redirects to this URL: https://doc-14-6o-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/lfmf9cfgfoj2o50tlamkia7cvn455but/1485957600000/11271801750769019286/*/0By7D4SJX3kYEdVo1bDdSb0hHWlk

3 comments:

  1. John, interesting approach. Just wondering why you wouldn't use the embed code provided when you share the image publicly? http://www.theedublogger.com/2017/02/08/google-photos/

    ReplyDelete
    Replies
    1. My application is for icons and other design elements for websites. I prefer to keep all of my files in Drive alongside the other resources for the site. I can also take advantage of the "replace" feature in Drive to auto-update an image without breaking the link.

      Delete
  2. NIce hack, but as you point out, Google can (and often does) break systems like this, so I wouldn't use it as the basis for an enduring project. Makes more sense to set up a plain 'ol FTP server somewhere and host images that way.

    ReplyDelete

Thanks for contributing to my blog. I enjoy being a part of the conversation and do my best to respond to comments and questions that are posted.