htmlimageurlgoogle-drive-apifile-sharing

img src html tag not loading public image from public shared google driver folder


I am trying to add an image into html document using google driver. I created a Public Folder by giving sharing options as Anyone with Link, and added images in that folder using same sharing option. However, it does not load. The URL used in the src attribute is obtained using another SO question here.

<td align="center" style="border-collapse:collapse;width:600px">
    <img src="https://drive.usercontent.google.com/download?id=1lHOxtnNsh88laZqNpZq8K4IA_Fpirtz9" alt="Rathsaptami3.JPG"></td>

I tried changing the URL to some other image address like amazon.com product image, and that image loads. Is there any change in the URL format for loading images from Google drive ?


Solution

  • In your situation, how about the following modification?

    Pattern 1:

    <td align="center" style="border-collapse:collapse;width:600px">
        <iframe src="https://drive.google.com/file/d/1lHOxtnNsh88laZqNpZq8K4IA_Fpirtz9/preview" allow="autoplay" alt="Rathsaptami3.JPG"></iframe></td>
    

    Pattern 2:

    <td align="center" style="border-collapse:collapse;width:600px">
        <img src="https://drive.google.com/thumbnail?sz=w512&id=1lHOxtnNsh88laZqNpZq8K4IA_Fpirtz9" alt="Rathsaptami3.JPG"></td>