Skip to content
Code-Schnipsel Gruppen Projekte
Commit a88a3b2b erstellt von Michael Danielczok's avatar Michael Danielczok
Dateien durchsuchen

fix: correct calc missing attribute (height or width) depends on image aspect ratio

Übergeordneter f73119fb
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -250,12 +250,13 @@ function smarty_function_image($params, $smarty)
$maxHeight = $Image->getHeight();
if ($maxWidth && $maxHeight) {
$ratio = round($maxWidth / $maxHeight);
$ratio = $maxWidth / $maxHeight;
}
} catch (Exception $Exception) {
QUI\System\Log::addDebug($Exception->getMessage());
}
// make sure the height and width are not greater than in original image
if (isset($params['width']) && $params['width'] > $maxWidth) {
$params['width'] = $maxWidth;
}
......@@ -264,12 +265,14 @@ function smarty_function_image($params, $smarty)
$params['height'] = $maxHeight;
}
// calc correct width or height if one of them is not passed in
// 1. rounds a number up - only integer is allowed als html width and height attribute
if ($ratio && empty($params['width']) && !empty($params['height'])) {
$params['width'] = $params['height'] * $ratio;
$params['width'] = ceil($params['height'] * $ratio); // (1)
}
if ($ratio && empty($params['height']) && !empty($params['width'])) {
$params['height'] = $params['width'] * $ratio;
$params['height'] = ceil($params['width'] / $ratio); // (1)
}
switch ($params['type']) {
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren