2

I created an image transform called teamImage. My template code is below.

I want this transform to be created when I upload an image within a Team entry.

Team has it's own asset folder.

My questions is how does craft know when to create this transform and where in the directory does it create it?

{% for asset in entry.teamImage %}
    <a href="{{ entry.url }}">
         <img src="{{ asset.getUrl('teamImage') }}" alt="{{ asset.title }}" />
    </a>
{% endfor %}
4

Craft will make the image transform the first time the template is loaded in the browser and the getUrl() is called. The image will at first be saved in a temporary directory, then moved into a sub-directory in your assets folder. The subdirectory will be descriptively named according to the type of transform. For example, if my template calls for a 500 x 500 center-center crop at 75% quality, it will be saved in /uploads/_500x500_crop_center-center_75/img.jpg.

This works similarly when using a CDN like S3 or Google Cloud.

| improve this answer | |
  • ok, that makes sense, but when I load the template in the browser the transform subfolder is not created. I have tried updating my image assets index. – seth Oct 6 '15 at 18:03
  • Do you have your transform defined in the template or in the control panel? If it is in the template, you should not add quotes around the transform name: {{ asset.getUrl(teamImage) }} – Aaron Berkowitz Oct 6 '15 at 18:04
  • I have it defined in the CP. – seth Oct 6 '15 at 18:07
  • Ok! When you inspect the element in the browser, is it showing the original image url or does it look different? Make sure you have devMode on too to see if there are any other errors happening. – Aaron Berkowitz Oct 6 '15 at 18:11
  • ok, got it sorted. my intended entry variable was actually teamMember. doh. – seth Oct 6 '15 at 18:16

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.