Skip to content
Grav 2.0 is officially stable. Read the announcement →
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 · 1010 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 Sebadamus, 2 days ago
2 63 20 hours ago
Themes & Styling · by martynfoster735, 4 days ago
1 155 3 days ago
Themes & Styling · by Justin Young, 2 weeks ago
1 218 2 weeks ago
Themes & Styling · by Slebeig, 1 month ago
4 348 1 month ago
Themes & Styling · by Pedro M, 3 months ago
4 703 3 months ago