Skip to content

Commit

Permalink
更新缩略图获取方式
Browse files Browse the repository at this point in the history
  • Loading branch information
donwa committed Apr 15, 2018
1 parent 5b632d5 commit 64bb66b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 6 additions & 8 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,13 @@
if ($items[$name]['folder']) {
header('Location: '.$_SERVER['REQUEST_URI'].'/');
}
if(in_array($_GET['thumbnails'],['large','medium','small'])){
list($time, $item) = cache('thumbnails_'.$path.$name);
if(empty($item[$_GET['thumbnails']]) || (TIME - $time) > config('cache_expire_time') ){
$item = onedrive::thumbnails($path.$name);
if(!empty($item)){
cache('thumbnails_'.$path.$name, $item);
}
if(!is_null($_GET['t']) && !empty($items[$name]['thumbnails'])){
$url = $items[$name]['thumbnails'][0]['large']['url'];
if(!empty($_GET['t'])){
list($width, $height) = explode('|', $_GET['t']);
list($url, $tmp) = explode("&width=",$url);
$url = $url."&width={$width}&height={$height}";
}
$url = $item[$_GET['thumbnails']]['url'];
}else{
$url = $items[$name]['downloadUrl'];
}
Expand Down
4 changes: 3 additions & 1 deletion lib/onedrive.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static function dir($path="/"){
if($path != '/'){
$path = ':'.rtrim($path, '/').':/';
}
$url = self::$app_url."_api/v2.0/me/drive/root".$path."children";
$url = self::$app_url."_api/v2.0/me/drive/root".$path."children?expand=thumbnails";
$resp = fetch::get($url);
$data = json_decode($resp->content, true);
if(!empty($data['@odata.nextLink'])){
Expand All @@ -87,12 +87,14 @@ static function dir($path="/"){
return false;
}
foreach((array)$data['value'] as $item){

$return[$item['name']] = array(
'name'=>$item['name'],
'size'=>self::human_filesize($item['size']),
'createdDateTime'=>strtotime($item['createdDateTime']),
'lastModifiedDateTime'=>strtotime($item['lastModifiedDateTime']),
'downloadUrl'=>$item['@content.downloadUrl'],
'thumbnails'=>$item['thumbnails'],
'folder'=>empty($item['folder'])?false:true
);
}
Expand Down

0 comments on commit 64bb66b

Please sign in to comment.