2

How can I output a resized Assets image in a single entry template? I'm trying to do what I used to do all the time with CE Image in EE. I'm hoping that I don't have to create an image transform in the CP for every single piece of image resizing that I want to do as that would be very time consuming (compared to using the CE Image parameters for width and height in EE).

Here's my current code:

{% for asset in entry.mainImage %}
  <img src="{{ asset.url }}" alt="{{ asset.title }}" />
{% endfor %}

And for EE users, here's what I'm trying to replicate from EE:

{cf_static_image}
  {exp:ce_img:single src="{url}" width="800" height="600" alt="{alt_text}"}
{/cf_static_image}

Thanks for any help in advance.

Update: Here's what my final code looked like after following the example in the link provided by Brad below:

{% set thumb = {
  mode: 'fit',
  width: 800,
  height: 600,
  quality: 80
} %}

{% for asset in entry.mainImage %}
  <img src="{{ asset.getUrl(thumb) }}" alt="{{ asset.title }}" />
{% endfor %}
2

You can dynamically create and specify transform parameters from your templates to achieve what you're looking for. See here for an example.

1
  • Thanks for this Brad. I've updated my question with what my final code ended up like after checking out that example. – Stephen Jan 20 '15 at 0:40

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.