Skip to content

Commit e325df1

Browse files
authored
Merge pull request #3761 from plentymarkets/fix/alt_text_from_webspace_images_for_manufacturer_images
fix: alt text from webspace images for manufacturer images
2 parents dcab025 + a58d2fe commit e325df1

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

meta/documents/changelog_de.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixed
66

77
- Fehlender Hinweis für erforderliche Adressfelder im Checkout.
8+
- Herstellerlogos werden jetzt mit dem im Webspace hinterlegten Alttext ausgegeben.
89

910
## v5.0.78 (2025-10-17) <a href="https://github.com/plentymarkets/plugin-ceres/compare/5.0.77...5.0.78" target="_blank" rel="noopener"><b>Übersicht aller Änderungen</b></a>
1011

meta/documents/changelog_en.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixed
66

77
- Missing asterix hint for required address input fields in checkout.
8+
- Manufacturer logos are now displayed with the alt text stored in the web space.
89

910
## v5.0.78 (2025-10-17) <a href="https://github.com/plentymarkets/plugin-ceres/compare/5.0.77...5.0.78" target="_blank" rel="noopener"><b>Overview of all changes</b></a>
1011

src/Extensions/TwigItemDataField.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace Ceres\Extensions;
44

5-
use IO\Helper\Utils;
65
use IO\Helper\SafeGetter;
6+
use IO\Helper\Utils;
77
use IO\Services\PropertyFileService;
8+
use Plenty\Modules\Webshop\Contracts\WebspaceRepositoryContract;
89
use Plenty\Plugin\Templates\Extensions\Twig_Extension;
910
use Plenty\Plugin\Templates\Factories\TwigFactory;
1011
use Plenty\Plugin\Templates\Twig;
@@ -29,6 +30,8 @@ class TwigItemDataField extends Twig_Extension
2930
*/
3031
private $itemData = [];
3132

33+
private const METADATA_ALT_TEXT_KEY = 'alttext';
34+
3235
/**
3336
* TwigItemDataField constructor.
3437
* @param TwigFactory $twig The factory to render TWIG.
@@ -160,7 +163,24 @@ public function getDataField($field, $filter = null, $directiveType = "text", $h
160163
}
161164

162165
if (in_array($htmlTagType, ['img'])) {
163-
$html = "<$htmlTagType $vueDirectiveAttr=\"$vueDirectiveValue\"$attributes v-if=\"$vueDirectiveValue\"/>";
166+
$twigPrintPath = is_string($twigPrint) ? trim($twigPrint) : '';
167+
$altText = '';
168+
if ($field === 'item.manufacturer.logo' && $twigPrintPath !== '') {
169+
/** @var WebspaceRepositoryContract $webspaceRepository */
170+
$webspaceRepository = pluginApp(WebspaceRepositoryContract::class);
171+
$altText = $webspaceRepository->getCdnMetadata(
172+
$twigPrintPath,
173+
self::METADATA_ALT_TEXT_KEY,
174+
''
175+
);
176+
}
177+
178+
if (is_string($altText) && strlen($altText) > 0) {
179+
$escapedAltText = htmlspecialchars($altText, ENT_QUOTES);
180+
$html = "<$htmlTagType $vueDirectiveAttr=\"$vueDirectiveValue\"$attributes alt=\"$escapedAltText\" v-if=\"$vueDirectiveValue\"/>";
181+
} else {
182+
$html = "<$htmlTagType $vueDirectiveAttr=\"$vueDirectiveValue\"$attributes v-if=\"$vueDirectiveValue\"/>";
183+
}
164184
} else {
165185
$html = "<$htmlTagType $vueDirectiveAttr=\"$vueDirectiveValue\"$attributes>$twigPrint</$htmlTagType>";
166186
}

0 commit comments

Comments
 (0)