Retina iconLink with Google Drive API

I'm an getting a list of files in a folder. The response contains a iconLink for every file returned. This icon is 16x16 pixels.

Does anyone know a way to retrieve a retina image? Or another way to retrieve a bigger icon image?

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

top : Google Drive UI

bottom : Google Drive API integration

例


The good news is although not officailly documented driver does have 2x resolution icons. The bad news is they have inconsistent file names; for example the icon you linked in the comments has a 32px version availabel here: ssl.gstatic.com/docs/doclist/images/mediatype/icon_3_pdf_x32.png

Now here is my soltion, it's not perfect but it will do the job for a while:

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'];
}

The reasion I say it will work for a while is that I'm asuming the _3_ in pdf icon file name for instance is the version number. So if Google updates it's icons again in the future this solution may brake.


Looks like images with x128 also added/present for various versions:

Ver. 1

Ver. 2

Ver. 3

Better to replace the x16 from the fetched iconLink and replace it with x128 .

链接地址: http://www.djcxy.com/p/32498.html

上一篇: 用多个蜘蛛跑无头的硒

下一篇: Retina iconLink与Google Drive API