3

I'm trying to call an image via an image transform from a matrix field.

So when I do this:

{% if block.type == "standardImage" %}
  {% set image = block.imageFile.first() %}
  {% if image %}
      <img src="{{ image.url('generalImageTransform') }}" width="{{ image.getWidth('generalImageTransform') }}" 
      height="{{ image.getHeight('generalImageTransform') }}" alt="{{ image.title }}">
  {% endif %}
{% endif %}

I get this:

<img src="http://.../cpresources/transforms/1?x=DrK2WYEvg" width="600" height="601" alt="district">

So you can see the width, height and title are all being called successfully, but the image is broken on the web page.

And when I skip the transform and just use {{ image.url() }} the image is called successfully with

<img src="/images/general/district.png" width="600" height="601" alt="district">

Finally when I add this to the config file

'generateTransformsBeforePageLoad' => true,

I get a PHP error

Image “district.png” cannot be found.

I suspect then that the transformed image is unable to be created, but I don't know how to progress this idea, or if I am on the right track at all.

4

I seem to have worked it out - by specifying

'imageDriver' => 'gd'

in the config. I first tried to specify 'imageDriver' => 'imagick', but I was getting path error messages so I'm guessing it is not installed on the PHP installation I am using.

More info at Errors with Craft 2.3, Imagine and Imagick

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.