{
protected static $_imagesizeCache = [];
+ /**
+ * @throws \Exception
+ */
public static function getimagesize($path)
{
if (isset(self::$_imagesizeCache[$path])) {
return self::$_imagesizeCache[$path];
}
+ if (!file_exists($path)) {
+ throw new \Exception('File ' . $path . ' does not exist');
+ }
+
+ $allowedExtensions = ['svg', 'oam', 'zip', 'jpeg', 'jpg', 'gif', 'png', 'webm'];
+
$ext = Files::getExtension($path);
+ if (!in_array($ext, $allowedExtensions)) {
+ throw new \Exception('File ' . $path . ' is not a valid image');
+ }
if ($ext === 'svg') {
$svg = simplexml_load_string(file_get_contents($path));
$attr = $svg->attributes();
if (!is_array($res)) {
$res = false;
} else {
- $res = array_slice($res, 0, 2, true);
+ if (!isset($res[2])) {
+ $res[2] = 0;
+ }
+ if (!isset($res[3])) {
+ $res[3] = 'width="' . $res[0] . '" height="' . $res[1] . '"';
+ }
}
self::$_imagesizeCache[$path] = $res;
return $res;