使用Google Drive API的Retina iconLink

Mar*_*oek 9 php google-drive-api

我是一个文件夹中的文件列表.响应包含 iconLink每个返回的文件.此图标为16x16像素.

有谁知道检索视网膜图像的方法?或者另一种检索更大图标图像的方法?

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

顶部:Google Drive UI

底部:Google Drive API集成

例

Aro*_*ron 3

好消息是,虽然没有正式记录的驱动程序确实有 2 倍分辨率的图标。坏消息是它们的文件名不一致;例如,您在评论中链接的图标在此处有一个 32px 版本:ssl.gstatic.com/docs/doclist/images/mediatype/icon_3_pdf_x32.png

现在这是我的解决方案,它并不完美,但它可以完成一段时间的工作:

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'];
}
Run Code Online (Sandbox Code Playgroud)

我说它会工作一段时间的原因是我假设_3_pdf 图标文件名是版本号。因此,如果谷歌将来再次更新它的图标,这个解决方案可能会失效。