From d14da5987dd676b05e1c8a73fc52a5fc52600652 Mon Sep 17 00:00:00 2001 From: yarooze Date: Thu, 19 Sep 2024 12:12:16 +0200 Subject: [PATCH] Update Media.php Added missing 'alt' attribute to Media node: https://developer.atlassian.com/cloud/jira/platform/apis/document/nodes/media/ --- src/Node/Child/Media.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Node/Child/Media.php b/src/Node/Child/Media.php index b3fbd3b..e595625 100644 --- a/src/Node/Child/Media.php +++ b/src/Node/Child/Media.php @@ -21,10 +21,11 @@ class Media extends Node private string $mediaType; private string $collection; private ?string $occurrenceKey; + private ?string $alt; private ?int $width; private ?int $height; - public function __construct(string $id, string $mediaType, string $collection, ?int $width = null, ?int $height = null, ?string $occurrenceKey = null, ?BlockNode $parent = null) + public function __construct(string $id, string $mediaType, string $collection, ?int $width = null, ?int $height = null, ?string $occurrenceKey = null, ?BlockNode $parent = null, ?string $alt = null) { if (!\in_array($mediaType, [self::TYPE_FILE, self::TYPE_LINK], true)) { throw new InvalidArgumentException('Invalid media type'); @@ -37,6 +38,7 @@ public function __construct(string $id, string $mediaType, string $collection, ? $this->occurrenceKey = $occurrenceKey; $this->width = $width; $this->height = $height; + $this->alt = $alt; } public static function load(array $data, ?BlockNode $parent = null): self @@ -51,7 +53,8 @@ public static function load(array $data, ?BlockNode $parent = null): self $data['attrs']['width'] ?? null, $data['attrs']['height'] ?? null, $data['attrs']['occurrenceKey'] ?? null, - $parent + $parent, + $data['attrs']['alt'] ?? null ); } @@ -85,6 +88,11 @@ public function getHeight(): ?int return $this->height; } + public function getAlt(): ?int + { + return $this->alt; + } + protected function attrs(): array { $attrs = parent::attrs(); @@ -105,6 +113,10 @@ protected function attrs(): array $attrs['height'] = $this->height; } + if (null !== $this->alt) { + $attrs['alt'] = $this->alt; + } + return $attrs; } }