2

I use a responsive image plugin similar to picturefill.

On my local environement it works well, on my live install however the last trasnform isn't applied and I receive a 404. I guess it might be some memory_limit issue, so I wonder if there is a more efficent way to write this:

{% set fullw_trans_xs = { mode: 'crop', width: 767, } %}
{% set fullw_trans_sm = { mode: 'crop', width: 768, } %}
{% set fullw_trans_md = { mode: 'crop', width: 992, } %}
{% set fullw_trans_lg = { mode: 'crop', width: 1200, } %}
<img class="bttr img-responsive" alt="{{asset.title}}"
   data-bttrlazyloading-xs='{"src": "{{ asset.getUrl(fullw_trans_xs) }}", "width" : {{ asset.getWidth(fullw_trans_xs) }},  "height" : {{ asset.getHeight(fullw_trans_xs) }}}'
   data-bttrlazyloading-sm='{"src": "{{ asset.getUrl(fullw_trans_sm) }}", "width" : {{ asset.getWidth(fullw_trans_sm) }},  "height" : {{ asset.getHeight(fullw_trans_sm) }}}'
   data-bttrlazyloading-md='{"src": "{{ asset.getUrl(fullw_trans_md) }}", "width" : {{ asset.getWidth(fullw_trans_md) }},  "height" : {{ asset.getHeight(fullw_trans_md) }}}'
   data-bttrlazyloading-lg='{"src": "{{ asset.getUrl(fullw_trans_lg) }}", "width" : {{ asset.getWidth(fullw_trans_lg) }},  "height" : {{ asset.getHeight(fullw_trans_lg) }}}'
            />

I saw the answer of Brandon Kelly about retina images with that macro thing but frankly, I don't get it. Could that be applied in some way to solve this problem as well?

  • 1
    Macros wouldn't help, they only enable you to write the code more DRY. But in the end, it'd trigger the same asset transforms as you have right now. – carlcs Aug 25 '14 at 7:23
  • 1
    What carlcs said. Also, did you make sure you had 'generateTransformsBeforePageLoad' => true, in your general.php file ? That's the best practice when using things like picturefill as it forces Craft to generate all transforms whatever the displayed images ends up being. – Jérôme Coupé Aug 25 '14 at 8:25
  • 1
    You can verify if it's a memory_limit issue by looking in your craft/storage/runtime/logs/phperrors.log file. – Brad Bell Aug 25 '14 at 14:54
  • I added 'generateTransformsBeforePageLoad' => true, and checked for phperrors.log but they are empty. The ima of fullw_trans_lg are still not generated. Any other way to debug this? – KSPR Aug 26 '14 at 14:10
0

Okay, I found the issue.

It was the caching. I cleared the cache in the cp and emptied the craft_assettransformindex table

I deploied the site to my live server but had the image folder on svnIgnore, so craft tought the images would still be there and didn't try to recreate them.

This answer helps.

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.