Hi!
I need some help to output media files and text in the right way.
Firsly I’ve uploaded images thourgh a admin panel and created meta files for them.
The html block was pretty simple:
{% for image in page.media.images %}
<div class="card">
<div class="service-feature-box">
<div class="service-media">
{{ image.cropResize(360,216).html }}
</div>
<div class="card-body">
<div class="service-body">
<div class="custom-heading">
<h4>{{ image.heading }}</h4>
</div>
<p class="text-justify">{{ image.description }}</p>
</div>
</div>
</div>
</div>
{% endfor %}
heading and description were inside meta file.
Now I need to reorganize this block in a proper way: the text is stored in .md files while meta data is stored in meta yaml file.
So, this is the full .md
file:
---
title: Services
menu: Portfolio
process:
markdown: true
twig: true
recaptchacontact:
enabled: false
text:
-
heading: 'Header 1'
description: 'desc1'
-
heading: 'Header 2'
description: 'desc2'
-
heading: 'Header 3'
description: 'desc3'
---
<section class="service-container container-fluid">
<div class="container py-4">
<div class="card-deck">
{% for item in page.header.text %}
<div class="card">
<div class="service-feature-box">
<div class="service-media">
{{ page.media.cropResize(360,216).html }}
{{ dump(page.media) }}
</div>
<div class="card-body">
<div class="service-body">
<div class="custom-heading">
<h4>{{ item.heading }}</h4>
</div>
<p class="text-justify">{{ item.description }}</p>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
<br>
</div>
</section>
In the same folder I’ve 3 images, like work1.jpg, work2.jpg, work3.jpg
and 3 meta files:
workN.jpg.meta.LANG_VAR.yaml
.
Meta files cotain some data:
title: Image title
alt_text: alt_image_text
So, as a result I’m getting output with text, but without images. While I need text + images(with metal data).
When I didn’t have to output a text, the
{% for image in page.media.images %}
{{ image.cropResize(360,216).html }}
did the trick for me, but that was valid only for images