Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Call each url image in the quark modular feature loop

Solved by Jared View solution

Started by Pedro Oliveira 8 years ago · 2 replies · 863 views
8 years ago

Hi, I copied the modular feature from quark theme, with small change of calling an image instead the fontawesome icon. With {{feature.bimg}} the file name shows as expected, but if I try {{feature.bimg.url}} it shows up empty.

I guess is something ridiculously simple, but I cant figure it out. Any help is appreciated.

Here's the code for twig:

<section id="modular-features-b" class="section {{ page.header.class}}">
<section class="container {{ grid_size }}">
<div class="frame-box">

TWIG
            {{ content }}

            <div class="columns">
            {% for feature in page.header.features %}
               <div class="column {{ columns }}">
                   <div class="feature-image">
                       {{ feature.bimg }}
                       {% if feature.header %}
                           <h6>{{ feature.header }}</h6>
                       {% endif %}
                   </div>
                   <div class="feature-content">
                       {% if feature.text %}
                        <p>{{ feature.text }}</p>
                       {% endif %}
                   </div>
               </div>
            {% endfor %}
            </div>
        </div>
    </section>

</section>

Cheers,
Pedro

last edited 05/08/18 by Pedro Oliveira
8 years ago Solution

Hi
Is {{ feature.bimg.url }} an actual field name or are you adding .url to try to make it into a url?

If you want to create a whole image link you can do it with this line:
{{ page.media.images[ feature.bimg ].html( feature.bimg.image_title , feature.bimg.image_alt, feature.bimg.img_class ) }}

The image title, alt and class are fields you would need to create or if you don't need all those you could do this:

{{ page.media.images[ feature.bimg ].url }}

👍 1
8 years ago

Hi,

I was trying to add .url to the feature.bimage variable with no avail.
Your last line worked perfectly.
I will test the line with class and alt for learning purposes.

Thank you, csixtyfour!
Pedro

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 193 2 months ago
Themes & Styling · by Ian, 2 months ago
3 91 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 451 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 45 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 125 3 months ago