Upgrade to 4.6.0
This commit is contained in:
@@ -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()) {
|
||||
|
Reference in New Issue
Block a user