Ist schon was länger her, wo ich das mal gemacht hatte. Nein, ohne weiter Schleife. Es geht so (gallery_default, bzw. gallery_first-only):
In der äußeren Schleife einen Zähler starten.
PHP-Code:
<?php $i = 0; foreach ($this->body as $class=>$row): ?>
In der inneren Schleife den Zähler hochzählen.
PHP-Code:
<?php foreach ($row as $col): $i++; ?>
Und dann mit if($i === 1) alles "aussperren", was man nur im 1. Durchlauf möchte.
PHP-Code:
<?php if($i === 1): ?>
<figure class="image_container"<?php if ($col->margin): ?> style="<?= $col->margin ?>"<?php endif; ?>>
<?php endif; ?>
<?php if ($col->href): ?>
<a href="<?= $col->href ?>"<?= $col->attributes ?> title="<?= $col->alt ?>">
<?php if($i === 1): ?>
<?php $this->insert('picture_default', $col->picture); ?>
<?php endif; ?>
</a>
<?php else: ?>
<?php if($i === 1): ?>
<?php $this->insert('picture_default', $col->picture); ?>
<?php endif; ?>
<?php endif; ?>
<?php if ($col->caption): ?>
<figcaption class="caption"><?= $col->caption ?></figcaption>
<?php endif; ?>
<?php if($i === 1): ?>
</figure>
<?php endif; ?>
Ich habe hier das Picture (Thumb) und auch das Figure rausgeworfen (habe ich in dem Post darüber nochmal geändert, weil man das Figure dann ja auch nicht benötigt.)
Lesezeichen