6

The image tag shown below prevents my {% cache %} tag from caching the loop it's in. If I remove the image tag or change the data-resource attribut to a normal src, it works fine. The class="lazy" and data-original are from the jQuery plugin Lazy Load 1.9.3. Regardless, the page still renders fine. Does anyone have any ideas what's wrong?

Thank you for your help for a first-time poster.

<img class="lazy" data-original="{{ image.getUrl(transform) }}" alt="{{ project.title }}" />

EDIT: Now showing just the code that seems to be the problem rather than the whole loop.

Willhaus
  • 201
  • 1
  • 9
  • Good to hear that you figured it out. Could you now please slim down your code to only the relevant parts to make this question helpful for others? – carlcs Jul 04 '14 at 09:21
  • Done. Thanks for the suggestion. Still wondering what makes the cache fail, though. – Willhaus Jul 04 '14 at 15:00

2 Answers2

8

The {% cache %} tag will detect if there are any ungenerated image transforms within it. If there are, it will hold off on caching the template until the next request, so that the temporary image URL won’t get cached.

Brandon Kelly
  • 34,307
  • 2
  • 71
  • 137
  • The image transform were actually generating fine. I could see them in the markup in the data-original attribute even before the plugin generated the src tag. – Willhaus Jul 11 '14 at 21:24
2

I finally got the chance to update Craft from 2.0 to 2.1 and that seems to have made the cache tag function as expected. (And it is terrific.)

Thanks for the help, Willhaus

Willhaus
  • 201
  • 1
  • 9