0

so I am using trying to use the Imager plugin to compress my images. It works fine this way:

    {% set imagePath = "/path/to/img.jpg" %}
    {% set compressed = craft.imager.transformImage(imagePath, { pngCompressionLevel: 9, webpQuality: 10, jpegQuality: 50 }) %}
    <img src="{{ compressed }}" alt="Foto-kantoor" class="img-max img-responsive wow fadeIn">

But if I try to use it inside a {% for %} loop it doesn't work and I get an error. Here's the code Im trying to use:

{% for image in logos %}
    {% if image %}
        <div class="img-frame">
            {% set compressed = craft.imager.transformImage(image, { pngCompressionLevel: 9, webpQuality: 10, jpegQuality: 50 }) %}
            <img src="{{ compressed.url }}" alt="Logo-{{ loop.index0 }}" class="img-responsive logo-img">
        </div>
    {% endif %}
{% endfor %}

Then I get this error:

Unable to open image /Applications/MAMP/htdocs/project/files/logos/my-logo.jpg

Does anyone know what Im doing wrong?

Thanks!

  • Any fatal errors in your craft/storage/runtime/logs files? My guess is you're hitting either your php.ini file's max_execution_time or memory_limit settings. – Brad Bell May 2 '17 at 21:14
  • @Branko Have you double checked that the file actually exists in the path specified? – André Elvan Jun 9 '17 at 11:01

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.