diff --git a/Block/Picture.php b/Block/Picture.php
index 521ff0d..334b169 100644
--- a/Block/Picture.php
+++ b/Block/Picture.php
@@ -249,6 +249,22 @@ public function getOriginalAttributesAsString(): string
return implode(' ', $this->getOriginalAttributes());
}
+ public function getSourceAttributesAsString(): string
+ {
+ $allowedSourceAttributes = ['media', 'sizes'];
+ $sourceAttributes = [];
+ foreach ($this->getOriginalAttributes() as $originalAttribute) {
+ $originalAttributeArray = explode('=', $originalAttribute);
+ if (false === in_array($originalAttributeArray[0], $allowedSourceAttributes)) {
+ continue;
+ }
+
+ $sourceAttributes[] = $originalAttribute;
+ }
+
+ return implode(' ', $sourceAttributes);
+ }
+
/**
* @return string[]
*/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b49354a..12cb8f0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
+### Fixed
+- Only re-use limited set of HTML attributes for source-tags #78
## [0.5.3] - 22 May 2024
### Fixed
diff --git a/Test/Integration/Block/PictureTest.php b/Test/Integration/Block/PictureTest.php
index 5d20d45..cec7e18 100644
--- a/Test/Integration/Block/PictureTest.php
+++ b/Test/Integration/Block/PictureTest.php
@@ -21,12 +21,18 @@ public function testPictureCreation()
$images = [new Image('/tmp/pub/images/test.webp', '/images/test.webp')];
$pictureFactory = $this->objectManager->create(PictureFactory::class);
- $picture = $pictureFactory->create($originalImage, $images, '');
+ $picture = $pictureFactory->create($originalImage, $images, '');
$html = $picture->toHtml();
$this->assertNotEmpty($html);
$this->assertStringContainsString('