mirror of
https://github.com/moodle/moodle.git
synced 2025-07-27 01:10:51 +02:00
MDL-71481 repository_flickr_public: return more file data.
A HTTP HEAD request is required to get the image filesize. The remaining data can be obtained from existing calls to the Flickr API.
This commit is contained in:
@@ -304,6 +304,7 @@ class repository_flickr_public extends repository {
|
|||||||
'user_id' => $nsid,
|
'user_id' => $nsid,
|
||||||
'license' => $licenses,
|
'license' => $licenses,
|
||||||
'text' => $text,
|
'text' => $text,
|
||||||
|
'extras' => 'original_format,license,date_upload,last_update',
|
||||||
'media' => 'photos'
|
'media' => 'photos'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -328,7 +329,8 @@ class repository_flickr_public extends repository {
|
|||||||
public function get_listing($path = '', $page = 1) {
|
public function get_listing($path = '', $page = 1) {
|
||||||
$people = $this->flickr->people_findByEmail($this->flickr_account);
|
$people = $this->flickr->people_findByEmail($this->flickr_account);
|
||||||
$this->nsid = $people['nsid'];
|
$this->nsid = $people['nsid'];
|
||||||
$photos = $this->flickr->people_getPublicPhotos($people['nsid'], 'original_format', 24, $page);
|
$photos = $this->flickr->people_getPublicPhotos($people['nsid'], 'original_format,license,date_upload,last_update',
|
||||||
|
24, $page);
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
return $this->build_list($photos, $page, $ret);
|
return $this->build_list($photos, $page, $ret);
|
||||||
@@ -382,16 +384,27 @@ class repository_flickr_public extends repository {
|
|||||||
// displaying broken thumbnails in the repository.
|
// displaying broken thumbnails in the repository.
|
||||||
$thumbnailsource = $OUTPUT->image_url(file_extension_icon($p['title'], 90))->out(false);
|
$thumbnailsource = $OUTPUT->image_url(file_extension_icon($p['title'], 90))->out(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Perform a HEAD request to the image to obtain it's Content-Length.
|
||||||
|
$curl = new curl();
|
||||||
|
$curl->head($this->get_link($p['id']));
|
||||||
|
|
||||||
|
// The photo sizes are statically cached, so we can retrieve image dimensions without another API call.
|
||||||
|
$bestsize = $this->get_best_size($p['id']);
|
||||||
|
|
||||||
$ret['list'][] = array(
|
$ret['list'][] = array(
|
||||||
'title' => $p['title'],
|
'title' => $p['title'],
|
||||||
'source' => $p['id'],
|
'source' => $p['id'],
|
||||||
'id' => $p['id'],
|
'id' => $p['id'],
|
||||||
'thumbnail' => $thumbnailsource,
|
'thumbnail' => $thumbnailsource,
|
||||||
'date' => '',
|
'datecreated' => $p['dateupload'],
|
||||||
'size' => 'unknown',
|
'datemodified' => $p['lastupdate'],
|
||||||
|
'size' => (int)($curl->get_info()['download_content_length']),
|
||||||
|
'image_width' => $bestsize['width'],
|
||||||
|
'image_height' => $bestsize['height'],
|
||||||
'url' => 'http://www.flickr.com/photos/' . $p['owner'] . '/' . $p['id'],
|
'url' => 'http://www.flickr.com/photos/' . $p['owner'] . '/' . $p['id'],
|
||||||
'haslicense' => true,
|
'license' => $this->license4moodle($p['license']),
|
||||||
'hasauthor' => true
|
'author' => $p['owner'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user