ungetestet und nur als Vorschlag
Code:
<?php if ( is_array( $this->product_gallery ) && !empty($this->product_gallery_reihenfolge) ): ?>
<?php
// Die Reihenfolge aus dem Datenbankfeld "product_gallery_reihenfolge" holen
$order = explode(',', $this->product_gallery_reihenfolge); // Angenommen, es ist eine kommagetrennte Liste der Bild-IDs
// Array für sortierte Galerie
$sortedGallery = array();
// Die Galerie in der gewünschten Reihenfolge sortieren
foreach ($order as $id) {
foreach ($this->product_gallery as $arrProductimage) {
foreach ($arrProductimage as $productImage) {
// Überprüfen, ob die Bild-ID mit der in der Reihenfolge übereinstimmt
if ($productImage->id == $id) {
$sortedGallery[] = $productImage; // Bild zum sortierten Array hinzufügen
}
}
}
}
?>
<?php if (!empty($sortedGallery)): ?>
<?php foreach ($sortedGallery as $productImage): ?>
<?php $GLOBALS['TL_HEAD'][] = '<meta property="og:image" content="' .$productImage->singleSRC .'" />'; ?>
<?php $imgCount++ ?>
<?php if ( $productImage->singleSRC ): ?>
<figure>
<div class="mask">
<img src="<?= $productImage->src ?>">
</div>
<?php if ($productImage->caption): ?>
<figcaption><?= $productImage->caption ?></figcaption>
<?php endif; ?>
</figure>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>