Fix warning when displaying PDF in Media manager

Trying to access array offset on value of type bool in
.../inc/JpegMeta.php on line 1322
This commit is contained in:
Damien Regad 2021-01-27 00:59:26 +01:00
parent c10f256a39
commit bbdbbeb873
1 changed files with 75 additions and 73 deletions

View File

@ -1317,79 +1317,81 @@ class JpegMeta {
$this->_info['file']['UnixTime'] = filemtime($this->_fileName);
// get image size directly from file
$size = getimagesize($this->_fileName);
$this->_info['file']['Width'] = $size[0];
$this->_info['file']['Height'] = $size[1];
// set mime types and formats
// http://php.net/manual/en/function.getimagesize.php
// http://php.net/manual/en/function.image-type-to-mime-type.php
switch ($size[2]){
case 1:
$this->_info['file']['Mime'] = 'image/gif';
$this->_info['file']['Format'] = 'GIF';
break;
case 2:
$this->_info['file']['Mime'] = 'image/jpeg';
$this->_info['file']['Format'] = 'JPEG';
break;
case 3:
$this->_info['file']['Mime'] = 'image/png';
$this->_info['file']['Format'] = 'PNG';
break;
case 4:
$this->_info['file']['Mime'] = 'application/x-shockwave-flash';
$this->_info['file']['Format'] = 'SWF';
break;
case 5:
$this->_info['file']['Mime'] = 'image/psd';
$this->_info['file']['Format'] = 'PSD';
break;
case 6:
$this->_info['file']['Mime'] = 'image/bmp';
$this->_info['file']['Format'] = 'BMP';
break;
case 7:
$this->_info['file']['Mime'] = 'image/tiff';
$this->_info['file']['Format'] = 'TIFF (Intel)';
break;
case 8:
$this->_info['file']['Mime'] = 'image/tiff';
$this->_info['file']['Format'] = 'TIFF (Motorola)';
break;
case 9:
$this->_info['file']['Mime'] = 'application/octet-stream';
$this->_info['file']['Format'] = 'JPC';
break;
case 10:
$this->_info['file']['Mime'] = 'image/jp2';
$this->_info['file']['Format'] = 'JP2';
break;
case 11:
$this->_info['file']['Mime'] = 'application/octet-stream';
$this->_info['file']['Format'] = 'JPX';
break;
case 12:
$this->_info['file']['Mime'] = 'application/octet-stream';
$this->_info['file']['Format'] = 'JB2';
break;
case 13:
$this->_info['file']['Mime'] = 'application/x-shockwave-flash';
$this->_info['file']['Format'] = 'SWC';
break;
case 14:
$this->_info['file']['Mime'] = 'image/iff';
$this->_info['file']['Format'] = 'IFF';
break;
case 15:
$this->_info['file']['Mime'] = 'image/vnd.wap.wbmp';
$this->_info['file']['Format'] = 'WBMP';
break;
case 16:
$this->_info['file']['Mime'] = 'image/xbm';
$this->_info['file']['Format'] = 'XBM';
break;
default:
$this->_info['file']['Mime'] = 'image/unknown';
if ($size = getimagesize($this->_fileName)) {
$this->_info['file']['Width'] = $size[0];
$this->_info['file']['Height'] = $size[1];
// set mime types and formats
// http://php.net/manual/en/function.getimagesize.php
// http://php.net/manual/en/function.image-type-to-mime-type.php
switch ($size[2]) {
case 1:
$this->_info['file']['Mime'] = 'image/gif';
$this->_info['file']['Format'] = 'GIF';
break;
case 2:
$this->_info['file']['Mime'] = 'image/jpeg';
$this->_info['file']['Format'] = 'JPEG';
break;
case 3:
$this->_info['file']['Mime'] = 'image/png';
$this->_info['file']['Format'] = 'PNG';
break;
case 4:
$this->_info['file']['Mime'] = 'application/x-shockwave-flash';
$this->_info['file']['Format'] = 'SWF';
break;
case 5:
$this->_info['file']['Mime'] = 'image/psd';
$this->_info['file']['Format'] = 'PSD';
break;
case 6:
$this->_info['file']['Mime'] = 'image/bmp';
$this->_info['file']['Format'] = 'BMP';
break;
case 7:
$this->_info['file']['Mime'] = 'image/tiff';
$this->_info['file']['Format'] = 'TIFF (Intel)';
break;
case 8:
$this->_info['file']['Mime'] = 'image/tiff';
$this->_info['file']['Format'] = 'TIFF (Motorola)';
break;
case 9:
$this->_info['file']['Mime'] = 'application/octet-stream';
$this->_info['file']['Format'] = 'JPC';
break;
case 10:
$this->_info['file']['Mime'] = 'image/jp2';
$this->_info['file']['Format'] = 'JP2';
break;
case 11:
$this->_info['file']['Mime'] = 'application/octet-stream';
$this->_info['file']['Format'] = 'JPX';
break;
case 12:
$this->_info['file']['Mime'] = 'application/octet-stream';
$this->_info['file']['Format'] = 'JB2';
break;
case 13:
$this->_info['file']['Mime'] = 'application/x-shockwave-flash';
$this->_info['file']['Format'] = 'SWC';
break;
case 14:
$this->_info['file']['Mime'] = 'image/iff';
$this->_info['file']['Format'] = 'IFF';
break;
case 15:
$this->_info['file']['Mime'] = 'image/vnd.wap.wbmp';
$this->_info['file']['Format'] = 'WBMP';
break;
case 16:
$this->_info['file']['Mime'] = 'image/xbm';
$this->_info['file']['Format'] = 'XBM';
break;
default:
$this->_info['file']['Mime'] = 'image/unknown';
}
}
} else {
$this->_info['file'] = array();