Possibly a very easy question. Let me explain my flow:

  1. I created an asset folder (images)
  2. I added the folder in the assets
  3. I created in image transforms 'square' which is an image of 500 by 500px.
  4. I added a custom field to my homepage called 'hoofdafbeelding' and added an image to it.

I call the image like so:

{{ entry.hoofdafbeelding.getUrl('square') }}

I get the following error:

Object of class Craft\ElementCriteriaModel could not be converted to string

What am I missing?! How can it be so hard to show an image?


You can have more than one Asset in any Assets field, so it always returns to you an array of assets. So you just need:

{{ entry.hoofdafbeelding.first().getUrl('square') }}

...assuming you want the first asset.

  • Got it, this works indeed. Should something as rudimentary as this not be explicitly explained in the docs? Mar 31 '17 at 6:27

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.