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.

General

Newbie Q: How to get the image url from custom image field

Started by Dion 7 years ago · 2 replies · 489 views
7 years ago

Hi, I have a custom image field and i want to get the url in twig.

test.yaml

header.slider:
type: file
label: Slider
type: file
destination: '@self'
description: Only .png, .jpg, .jpeg file types are allowed.
multiple: true
style: vertical
accept:

  • .png
  • .jpg
  • .jpeg
    ordering@: 2

test.html.twig

{% extends 'partials/base.html.twig' %}

{% block content %}
{% for slide in page.header.slider.images %}
<img src="{{ slide.url }}">
{% endfor %}
{% endblock %}

7 years ago

@dimitrilongo, This is actually what i'm looking for. Thank you very much.

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 3 days ago
2 70 5 hours ago
General · by pamtbaau, 10 hours ago
1 45 9 hours ago
General · by Andy Miller, 22 hours ago
0 43 22 hours ago
General · by Marcel, 12 months ago
6 341 4 days ago
General · by Duc , 5 days ago
3 35 5 days ago