我正在获取文件夹中的文件列表。响应包含每个返回文件的 iconLink
。这个图标是 16x16 像素。
有谁知道检索视网膜图像的方法吗?或者另一种获取更大图标图像的方法?
https://developers.google.com/drive/v2/reference/files
顶部:Google 云端硬盘用户界面
底部:Google Drive API 集成
最佳答案
好消息是虽然没有正式记录的驱动程序确实有 2x 分辨率图标。坏消息是它们的文件名不一致;例如,您在评论中链接的图标在此处有一个 32 像素的版本: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'];
}
我说它会工作一段时间的原因是我假设 pdf 图标文件名中的 _3_
是版本号。因此,如果 Google 将来再次更新其图标,则此解决方案可能会失效。
关于php - 视网膜图标与 Google Drive API 的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35781392/