Skip to content
Snippets Groups Projects
Commit d21cdd34 authored by Maja Górecka-Wolniewicz's avatar Maja Górecka-Wolniewicz
Browse files

fixed SVG logo handling

parent 7354e62e
Branches
Tags
No related merge requests found
......@@ -104,15 +104,30 @@ foreach ($_POST as $k=>$v) {
} else {
$result[] = 'OKLOCAL';
}
$skipcheck = false;
if ($suffix == 'svg') {
$xmlget = simplexml_load_string($imageData);
$xmlattributes = $xmlget->attributes();
try {
$xmlget = simplexml_load_string($imageData);
if ($xmlget !== false) {
$xmlattributes = $xmlget->attributes();
} else {
$result[] = "ERROR: not SVG image";
$xmlattributes = NULL;
$skipcheck = true;
}
} catch (Exception $e) {
$result[] = "ERROR: not SVG image";
$skipcheck = true;
}
if ($xmlattributes) {
$width = $xmlattributes->width;
$height = $xmlattributes->height;
$size = array($width, $hight);
$size = array($width, $height);
}
} else {
$size = getimagesize($fileName);
}
if (!$skipcheck) {
if ($size === false && !preg_match('/\.svg$/i', $limg)) {
$result[] = "ERROR: The downloaded logo does not seem to be a PNG, JPG, GIF, SVG or a generally accepted image file format. Therefore, it most probably will not be displayed by web browsers.";
}
......@@ -132,6 +147,7 @@ foreach ($_POST as $k=>$v) {
if ($width && $height && isset($size[0]) && isset($size[1]) && round(10*$width/$height) != round(10*$size[0]/$size[1])) {
$result[] = "WARNING: Mismatching proportions (".$width.'px:'.$height."px=".round($width/$height,1)." in metadata vs ".$size[0].'px:'.$size[1].'px='.round($size[0]/$size[1],1)." actual). The logo will be displayed distorted by Discovery Services and Service Providers.";
}
}
$res = array('result' => '', 'url' => '');
if ($remote != '') {
$res['url'] = $remote;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment