Skip to content

Bagaimana Caranya Mendeteksi Laman yang Memiliki Satu Gambar atau Lebih? #183

Discussion options

You must be logged in to vote
<?php if ($images = $page->images): ?>
  <?php if (count($images) > 1): ?>
    <!-- Images as carousel -->
    <?php foreach ($images as $image): ?>
      <?= $image; ?>
      <br>
    <?php endforeach; ?>
  <?php else: ?>
    <!-- Image as figure -->
    <?= reset($images); ?>
  <?php endif; ?>
<?php else: ?>
  <?php if ($image = $page->image): ?>
    <!-- Image as figure -->
    <?= $image; ?>
  <?php else: ?>
    <!-- No image -->
  <?php endif; ?>
<?php endif; ?>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yuliakbard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants