0

I would like to display images from various sections, in this case the home page. I am still coming to terms with Twig/Craft's criteria models and the transform makes it confusing.

{% for image in craft.entries.section('news').limit(1) %}
    {% set transformedImage = craft.imager.transformImage(image, { width: 1420, height: 550, position: image.focalPoint }) %}

    <img src="{{ image.bannerImage.first().getUrl }}" alt="" />
{% endfor %}` 

Where do you then define the image? (bannerImage is a asset field)

  • Can you please rewrite this question so it has context for other people who may be viewing. – Fyrebase Jan 9 '17 at 7:08
2

Try the following, it should do what you are after.

{#
  Generate array of entries comprised of first
  entry from each section
#}
{% set entries = [
  craft.entries.section('news').first(),
  craft.entries.section('other_section').first(),
  craft.entries.section('yet_another_section').first()
] %}

{# Loop through entry array #}
{% for entry in entries %}
  {% if entry.bannerSlider|length %}
    {% set image = entry.bannerSlider.first() %}
    {% set transformedImage = craft.imager.transformImage(image, { width: 1420, height: 550, position: image.focalPoint,  effects: { grayscale: true, gamma: 1.5}, }) %}
    <li data-transition="" data-masterspeed="500">
    <img src="{{ transformedImage.url }}"/>
  {% endif %}
{% endfor %}

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.