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