0

Hi how do I access an image from a different entry / page /url? I'm building in Craft CMS.

I'm creating a nav that will be used across the site. It works fine and I can pull the title and page url ok. I want to use a picture from that page as a thumbnail for the link but it doesn't work.

On my page I have 4 or 5 featured images but I just want to access the first one. What ever I try doesn't work

{% set image = craft.entries.id(50 ####this is the page ID that the image is attached to).featuredImages %} - doesn't work.

Basically how do I access an image when all I have is the id number of the page it is attached on?

Any help would be much apreciated,

Thanks.

andreas
  • 16,357
  • 12
  • 72
  • 76

1 Answers1

0

Phew, found it. Perhaps there's a cleaner way but:

{% set pageData = entry.id(50) %} ## or in my case swap 50 with node.entryId as I'm using Navee plugin to build my nav. 

{% set x = 1 %}

{% for image in pageData.featuredImages %}

    {% if x == 1 %}

        <img class="navImage" src="{{ image.getUrl('siteThumb') }}" alt="{{ page.title }}">
        {% set x = 2 %}

    {% endif %}
{% endfor %}