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.

Support

Upload and show a image with Flex-Directory

Solved by andre_ani View solution

Started by andre_ani 7 years ago · 3 replies · 804 views
7 years ago

Hello,

I've modified the Flex-Directory plugin with my own label.
Now, I'm trying to add a label to upload an image.
It's working in the admin, the label is here and the file is uploaded.
But the image don't appear in the page.

I've had these lines in the site.html.twig file

TWIG
{% if entry.captures %}
       <p><span class="name">{{ entry.captures }}</span></p>
{% endif %}  

And these lines in the entries-list.html.twig

TWIG
<td>
      {{ entry.description }}
</td>

What's wrong with this ?
Any help please ?

Thanks,

andre_ani

7 years ago

I add this to the site.html.twig file but it's not working.

{% if entry.captures %}
<p><span class="name">{{ entry.captures }}</span></p>
<img src="/user/data/flex-directory/files/{{ entry.captures }}" />
{% endif %}

I finally find this https://learn.getgrav.org/16/cookbook/twig-recipes#displaying-an-image-uploaded-in-a-file-field

But the image is not appear... If I look at the code of the page, I have array in place of the name of the image.

last edited 05/14/19 by andre_ani
7 years ago

I don't understand this code ```
{{ page.media[header.yourfilefield|first.name] }}

TWIG


In the home page, I want to display the result of the Flex-directory plugin.
The name of the form for the file is {{ entry.captures }}
All of the other items are displaying. I don't know who to access to the image that are upload in /user/data/flex-directory/files/ with random name.

Any suggestions please ?
7 years ago Solution

It's working, finally, I found the solution

{% for key in entry.captures|keys %}
<img class="card-img-top" src=" {{ url(key) }} " alt="Card image cap">
{% endfor %}

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 54 12 hours ago
Support · by Anna, 3 days ago
2 60 15 hours ago
Support · by Justin Young, 16 hours ago
1 30 15 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 57 5 days ago