Unfortunately I'm still very new to Craft, but I have a question to which I haven't found an answer here or in the Docs or the ones I found don't seem to work: Why doesn't this entry-loop output a picture? Because the image title is output correctly and the transformation medium exists.

{% for entry in craft.entries
    .limit(1) %}
<a href="{{{ entry.url }}">
    {% set image = entry.image.one() %}
    {% if image %}
        <img src="{{ image.getUrl('Medium') }}" alt="{{{ image.title }}" />
    {% endif %}
{% endfor %}

thanks for help!

  • 1
    The value you pass to getUrl is the handle of a valid Transform—usually, those are all lowercase… can you double-check that this is what's entered in the Handle field, in the admin? Feb 10 '20 at 4:27
  • oh, that was my mistake - i had tried so much different code, that i used an example with a wrong handle here. Sorry! That wasn't the problem, but your question led me to the solution in a roundabout way, because I saw that Craft hadn't created any transformations: I didn't specify the path for public URLs in the assets, because I didn't know what this option is for and if you need it, because it appears optional. What is this option for? Thanks for your quick help!
    – Matthias
    Feb 10 '20 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.