TransWikia.com

{{ entry.image.first().url }} won't show image

Craft CMS Asked by Fritko on December 20, 2020

I am on my first Craft CMS test site. Have some problems showing a simple image.

<img src="{{ entry.hero.first().url }}" title="{{ hero.title }}">

I get the title but can’t get the URL. The src attr is always empty. Tried a couple of variants like:

  • entry.hero.first().url()
  • entry.hero.first().getUrl()
  • with and without ()
  • etc.

But entry.hero.first().filename gives me "my_testfile01.jpg"

I can’t see what is wrong.

File is local with path set to "./"
Image field has no sub path.

MAMP (Apache + PHP 7)

2 Answers

Is the "Assets in this volume have public URLs" turned on?

Answered by Ottó Radics on December 20, 2020

By the way, is your Craft CMS version 3.x? If so, using "one" is recommended instead of "first", which is deprecated.

Answered by Kota.M on December 20, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP