Update Composer packages

This commit is contained in:
Paul Nicoué 2023-04-14 16:34:06 +02:00
parent 67c3d8b307
commit 83cb211fe6
219 changed files with 6487 additions and 4444 deletions

View file

@ -33,7 +33,7 @@ class GdLib extends Darkroom
$image = $this->blur($image, $options);
$image = $this->grayscale($image, $options);
$image->toFile($file, $mime, $options['quality']);
$image->toFile($file, $mime, $options);
return $options;
}
@ -60,7 +60,11 @@ class GdLib extends Darkroom
return $image->resize($options['width'], $options['height']);
}
return $image->thumbnail($options['width'], $options['height'] ?? $options['width'], $options['crop']);
return $image->thumbnail(
$options['width'],
$options['height'] ?? $options['width'],
$options['crop']
);
}
/**

View file

@ -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);
}
}
}

View file

@ -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;
}
/**

View file

@ -2,6 +2,7 @@
namespace Kirby\Image;
use Kirby\Cms\Content;
use Kirby\Exception\LogicException;
use Kirby\Filesystem\File;
use Kirby\Toolkit\Html;
@ -112,6 +113,17 @@ class Image extends File
*/
public function html(array $attr = []): string
{
// if no alt text explicitly provided,
// try to infer from model content file
if (
$this->model !== null &&
method_exists($this->model, 'content') === true &&
$this->model->content() instanceof Content &&
$this->model->content()->get('alt')->isNotEmpty() === true
) {
$attr['alt'] ??= $this->model->content()->get('alt')->value();
}
if ($url = $this->url()) {
return Html::img($url, $attr);
}