For content inside my “blog”-directory, I would like to (1) fetch and output image meta data, also I would like to (2) filter by image meta data.
Here is the code I have:
<?php foreach($site->find('blog')->children()->limit(10) as $article): ?> <?php if($image = $article->image()): ?> <figure> <img src="<?= $image->url() ?>" alt="<?= $image->title() ?>"> </figure> <?php endif ?> <p><a href="<?php echo $article->url() ?>"><?php echo $article->title()->html() ?></a> <br><?php echo $article->description() ?></p> <?php endforeach ?>
The meta data by which I would like to filter is stored inside a meta data file. Specifically, it looks like this:
So, I would like to fetch images only with “product-image” as their category.
(2) output meta data
Sadly, this part doesn’t output anything:
alt="<?= $image->title() ?>"
I don’t know why. Can you help? Thank you.