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()
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)
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
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP