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.

2
  • 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
    Commented Jul 4, 2014 at 9:21
  • Done. Thanks for the suggestion. Still wondering what makes the cache fail, though.
    – Willhaus
    Commented Jul 4, 2014 at 15:00

2 Answers 2

8
+50

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.

1
  • 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
    Commented Jul 11, 2014 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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