2016-12-02 109 views
1

我想爲我的網站嵌入一個圖標。相關的HTML應通過我的Google雲端硬盤上的文件夾中的「src = ...」來檢索它。我給了該文件夾和圖像文件的公共訪問權限。 (最後我希望HTML代碼在Google平臺上運行,但我也可以用本地存儲的HTML文件來演示此問題。)對Google雲端硬盤上的圖片文件的HTML引用不起作用

當我使用指向我的文件夾的鏈接或直接在我的圖像文件瀏覽器,他們出現了。因此,我認爲沒有權威問題。另外,當我在本地PC上使用對圖像文件副本的引用時,它可以正常工作。

以下代碼顯示4種情況。前兩個指的是本地存儲的文件,最後兩個指的是Google驅動器上的文件,不起作用。

 <!DOCTYPE html> 
    <html> 
    <head> 
    Test on local PC 
    <br><br> 
    </head> 
    <body> 

    1. Image from same directory in which this html code resides 
    <br> 
    Method: src="test.png" 
    <br> 
    <img id="myImg" src="test.png" width="50" height="50"> 
    <br> 

    2. Image from directory on local PC 
    <br> 
    Method: src="C:/Users/MattheisenP/Desktop/test.png" 
    <br> 
    <img id="myImg" src="C:/Users/MattheisenP/Desktop/test.png" width="50" height="50"> 
    <br> 

    3. Image from directory on Google Drive using the drive's key 
    <br> 
    Method: src="https://drive.google.com/drive/folders/0B9P-4EpF1HhMXzdoQ2tJSXotVmc/test.png" 
    <br> 
    Using this url... https://drive.google.com/drive/folders/0B9P-4EpF1HhMXzdoQ2tJSXotVmc in the browser brings me to the folder 
    <br> 
    <img id="myImg" src="https://drive.google.com/drive/folders/0B9P-4EpF1HhMXzdoQ2tJSXotVmc/test.png" width="50" height="50"> 
    <br> 


    4. Image from directory on Google Drive using the files key 
    <br> 
    Method: src= "https://drive.google.com/file/d/0B9P-4EpF1HhMb0trR1NXbVhXNTg" 
    <br> 
    Using this url... https://drive.google.com/file/d/0B9P-4EpF1HhMb0trR1NXbVhXNTg in the browser displays the icon 
    <br> 
    <img id="myImg" src="https://drive.google.com/file/d/0B9P-4EpF1HhMb0trR1NXbVhXNTg" width="50" height="50"> 
    <br> 
    </body> 

結果如下: enter image description here

正如你看到的,最後兩個失敗。我的語法或對概念的理解有什麼問題?

感謝您的任何有幫助的提示。

回答

0

現在我發現了一個可用的語法: https://docs.google.com/uc?id=用FileID增強。在上面的例子中,聲明

 <img id="myImg" src="https://docs.google.com/uc?id=0B9P-4EpF1HhMb0trR1NXbVhXNTg" width="50" height="50"> 

給出預期結果並顯示圖標。所以,文件ID是正確的以及訪問權限。但是,在上面的案例3和4中使用的幾篇文章中提出的方法/語法不起作用(至少不適用於我)。使用https://docs.google.com/uc?id=的語法根據需要提供圖像。

相關問題