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 %}

1 Answer 1

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.

8
  • 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
    Commented Oct 6, 2015 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) }} Commented Oct 6, 2015 at 18:04
  • I have it defined in the CP.
    – seth
    Commented Oct 6, 2015 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. Commented Oct 6, 2015 at 18:11
  • ok, got it sorted. my intended entry variable was actually teamMember. doh.
    – seth
    Commented Oct 6, 2015 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.