Upgrade to 4.6.0

This commit is contained in:
Bastian Allgeier
2025-01-30 12:15:44 +01:00
parent d71db84033
commit daf499e2e4
179 changed files with 1848 additions and 688 deletions

View File

@@ -2,6 +2,7 @@
namespace Kirby\Image;
use Kirby\Cms\FileVersion;
use Kirby\Content\Content;
use Kirby\Exception\LogicException;
use Kirby\Filesystem\File;
@@ -115,15 +116,20 @@ class Image extends File
*/
public function html(array $attr = []): string
{
$model = match (true) {
$this->model instanceof FileVersion => $this->model->original(),
default => $this->model
};
// 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
$model !== null &&
method_exists($model, 'content') === true &&
$model->content() instanceof Content &&
$model->content()->get('alt')->isNotEmpty() === true
) {
$attr['alt'] ??= $this->model->content()->get('alt')->value();
$attr['alt'] ??= $model->content()->get('alt')->value();
}
if ($url = $this->url()) {