1

I have entries that contain a single graphic asset. I'm trying to use the graphic as a background image in my template. However, I'm unable to output the URI for the asset. I'm using entry.graphic.first().url but I get an error that the property is null. I'm using the dbug plugin to look at the properties and can see that the asset is being returned, however the URI property is null.

I am looping through entries and am unable to return the URI for any of the graphics. Any ideas?

Thanks!

EDIT: Sorry for the lack of code, guys! Below is my whole content block for the page so far.

<div class="container archive">
  <h1>Video Archives</h1>

  {% for entry in craft.entries.section('watch').order('seriesStart desc').type('series') %}
    {% set thumb = entry.graphic.first() %}
    <div class="col-md-3 seriesthumb" style="background-image: url('{{thumb.url}}');"></div>
  {% endfor %}

</div>

Thanks for the help!

  • I've noticed that if I try and pull the graphic's URI outside of the loop, I'm able to return it. It's when it's in the loop that I can't get the URI. – anguiac7 Apr 23 '15 at 2:01
  • What loop? Are you overwriting entry with that? – carlcs Apr 23 '15 at 5:45
  • Hi anguiac! Can you please edit your question to include a larger code sample? What you've provided so far isn't enough to determine what may be the problem. – Lindsey D Apr 23 '15 at 6:02
  • After {% set thumb = entry.graphic.first() %}, if you {{ thumb | dbug }}, is it the image you're expecting? – Brad Bell Apr 23 '15 at 16:52
  • @BradBell yes, I see the properties for the image, but the URI property is NULL. I've re-uploaded and cleared the asset cache but nothing helped. – anguiac7 Apr 23 '15 at 23:09
1

Through Pixel and Tonic's support email, I figured out what the issue was. It turns out one of my entries didn't have a thumbnail and that was why the image was null. Stupid user error! I thought I had checked to make sure everything was good but I guess not. Thanks for the help @BradBell.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.