Upgrade to 3.9.0
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Kirby\Image;
|
||||
|
||||
use Kirby\Toolkit\Str;
|
||||
|
||||
/**
|
||||
* The Dimension class is used to provide additional
|
||||
* methods for images and possibly other objects with
|
||||
@@ -253,12 +255,28 @@ class Dimensions
|
||||
|
||||
if ($xml !== false) {
|
||||
$attr = $xml->attributes();
|
||||
$width = (int)($attr->width);
|
||||
$height = (int)($attr->height);
|
||||
if (($width === 0 || $height === 0) && empty($attr->viewBox) === false) {
|
||||
$box = explode(' ', $attr->viewBox);
|
||||
$width = (int)($box[2] ?? 0);
|
||||
$height = (int)($box[3] ?? 0);
|
||||
|
||||
$rawWidth = $attr->width;
|
||||
$width = (int)$rawWidth;
|
||||
$rawHeight = $attr->height;
|
||||
$height = (int)$rawHeight;
|
||||
|
||||
// use viewbox values if direct attributes are 0
|
||||
// or based on percentages
|
||||
if (empty($attr->viewBox) === false) {
|
||||
$box = explode(' ', $attr->viewBox);
|
||||
|
||||
// when using viewbox values, make sure to subtract
|
||||
// first two box values from last two box values
|
||||
// to retrieve the absolute dimensions
|
||||
|
||||
if (Str::endsWith($rawWidth, '%') === true || $width === 0) {
|
||||
$width = (int)($box[2] ?? 0) - (int)($box[0] ?? 0);
|
||||
}
|
||||
|
||||
if (Str::endsWith($rawHeight, '%') === true || $height === 0) {
|
||||
$height = (int)($box[3] ?? 0) - (int)($box[1] ?? 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -215,9 +215,10 @@ class Exif
|
||||
*/
|
||||
protected function parseFocalLength(): string|null
|
||||
{
|
||||
return $this->data['FocalLength'] ??
|
||||
$this->data['FocalLengthIn35mmFilm'] ??
|
||||
null;
|
||||
return
|
||||
$this->data['FocalLength'] ??
|
||||
$this->data['FocalLengthIn35mmFilm'] ??
|
||||
null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -112,6 +112,12 @@ class Image extends File
|
||||
*/
|
||||
public function html(array $attr = []): string
|
||||
{
|
||||
// if no alt text explicitly provided,
|
||||
// try to infer from model content file
|
||||
if ($alt = $this->model?->alt()) {
|
||||
$attr['alt'] ??= $alt;
|
||||
}
|
||||
|
||||
if ($url = $this->url()) {
|
||||
return Html::img($url, $attr);
|
||||
}
|
||||
|
Reference in New Issue
Block a user