2016-03-03 36 views
7

我正在獲取文件夾中的文件列表。對於每個返回的文件,響應都包含一個iconLink。這個圖標是16x16像素。視網膜iconLink與Google Drive API

有沒有人知道一種方式來檢索視網膜圖像?或者另一種方式來檢索更大的圖標圖像?

https://developers.google.com/drive/v2/reference/files

頂部:谷歌驅動器UI

底部:谷歌雲端硬盤API集成

Example

+0

到目前爲止你做了什麼?在每個返回的文件中,你是否嘗試過在更大的圖標中重新調整圖標圖像的大小? –

+0

返回的圖標網址導致16x16像素的圖像。 (例如https://ssl.gstatic.com/docs/doclist/images/icon_12_pdf_list.png)。我試圖添加@ 2x來查看是否可用,但到目前爲止還沒有運氣 –

+0

您是否找到了解決方案? –

回答

3

好消息是,雖然沒有officailly證明司機確實有2倍的分辨率圖標。壞消息是他們有不一致的文件名;比如你在評論中鏈接的圖標有一個32PX版本availabel這裏:ssl.gstatic.com/docs/doclist/images/mediatype/icon_3_pdf_x32.png

現在,這裏是我的soltion,它並不完美,但它會一會做的工作:

function getIcons($file_type) 
{ 
    $icons = [ 
     'pdf' => [ 
      'icon' => 'icon_12_pdf_list.png', 
      'retina' => 'icon_3_pdf_x32.png' 
     ], 
     'document' => [ 
      'icon' => 'icon_1_document_x16.png', 
      'retina' => 'icon_1_document_x32.png' 
     ], 
     'image' => [ 
      'icon' => 'con_1_image_x16.png', 
      'retina' => 'icon_1_image_x32.png' 
     ], 
     'word' => [ 
      'icon' => 'icon_1_word_x16.png', 
      'retina' => 'icon_1_word_x32.png' 
     ], 
     'text' => [ 
      'icon' => 'icon_1_text_x16.png', 
      'retina' => 'icon_1_text_x32.png' 
     ], 
     'spreadsheet' => [ 
      'icon' => 'icon_1_spreadsheet_x16.png', 
      'retina' => 'icon_1_spreadsheet_x32.png' 
     ], 
     'form' => [ 
      'icon' => 'icon_2_form_x16.png', 
      'retina' => 'icon_2_form_x32.png' 
     ], 
     'audio' => [ 
      'icon' => 'icon_1_audio_x16.png', 
      'retina' => 'icon_1_audio_x32.png' 
     ] 
    ]; 

    return isset($icons[$file_type]) ? $icons[$file_type] : $icons['text']; 
} 

的reasion我說它會工作一段時間,我認爲_3_在pdf圖標文件名稱例如是版本號。所以如果Google今後再次更新它的圖標,這個解決方案可能會制動。

0

看起來像X128圖像還添加/存在用於各種版本:

Ver. 1

Ver. 2

Ver. 3

更好

到從取出iconLink替換x16並用x128取代它。