Skip to content

Commit

Permalink
MDL-32914 fixed function get_imageinfo() to get rid of notice messages
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed May 21, 2012
1 parent 9a62f77 commit b7725e3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/filestorage/stored_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,14 @@ public function archive_file(file_archive $filearch, $archivepath) {
* @return mixed array with width, height and mimetype; false if not an image
*/
public function get_imageinfo() {
if (!$imageinfo = getimagesize($this->get_content_file_location())) {
$path = $this->get_content_file_location();
if (!is_readable($path)) {
if (!$this->fs->try_content_recovery($this) or !is_readable($path)) {
throw new file_exception('storedfilecannotread', '', $path);
}
}
$mimetype = $this->get_mimetype();
if (!preg_match('|^image/|', $mimetype) || !filesize($path) || !($imageinfo = getimagesize($path))) {
return false;
}
$image = array('width'=>$imageinfo[0], 'height'=>$imageinfo[1], 'mimetype'=>image_type_to_mime_type($imageinfo[2]));
Expand Down

0 comments on commit b7725e3

Please sign in to comment.