# Show a single image from a different section

**URL:** <https://forum.getkirby.com/t/show-a-single-image-from-a-different-section/31396>\
**Category:** Questions\
**Tags:** v4\
**Created:** [April 18, 2024, 9:37am UTC](https://forum.getkirby.com/t/show-a-single-image-from-a-different-section/31396 "2024-04-18T09:37:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martagnan](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/martagnan/32/14691_2.png) [@Martagnan](https://forum.getkirby.com/u/Martagnan)\
**Post date:** [April 18, 2024, 9:37am UTC](https://forum.getkirby.com/t/show-a-single-image-from-a-different-section/31396/1 "2024-04-18T09:37:09Z")

</div>

Hi,  
I’m sorry, i’m trying to learn PHP but i’m stumped with this…

On a website homepage I want to ‘pull’ information from the “Services” section of the website. After trying multiple variations of code I thought _might_ work I have given up and come here for help 😕

The url, title and IntroParagraph from the Services ‘pages’ are showing as expected but I cannot get the image to display! The blueprint field name is ‘MainHeroImage’

H have the following in my homepage template:

```auto
                    <?php foreach ($pages->find('services')->children()->listed() as $item): ?>
                        <li class="home-service-card">
                            <a href="<?= $item->url() ?>">
                                <h2><?= $item->title() ?></h2>
                                <p><?= $item->IntroParagraph() ?></p>
                                <?php if ($image = $item->MainHeroImage()->toFile()): ?>
                                <div class="img">
                                    <img src="<?= $image->url() ?>" alt="">
                                </div>
                                <?php endif ?>
                            </a>
                        </li>
                    <?php endforeach ?>

```

Thanks for any advice

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [April 18, 2024, 10:41am UTC](https://forum.getkirby.com/t/show-a-single-image-from-a-different-section/31396/2 "2024-04-18T10:41:13Z")

</div>

Could you post the blueprint please? If `MainHeroImage` was indeed a field, the code should work as expected. But I have a feeling it is not.

---

<div class="post-metadata">

**Author:** ![Martagnan](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/martagnan/32/14691_2.png) [@Martagnan](https://forum.getkirby.com/u/Martagnan)\
**Post date:** [April 18, 2024, 10:53am UTC](https://forum.getkirby.com/t/show-a-single-image-from-a-different-section/31396/3 "2024-04-18T10:53:34Z")

</div>

Thank you. Here’s the blueprint …

```auto
Title: Service

tabs:
  content:
    label: Content
    icon: text

    columns:

      main:
        width: 2/3

        sections:
          Hero:
            type: fields
            fields:
              HeroHeadline:
                type: text
                label: Hero Headline
              IntroParagraph:
                type: textarea
                label: Hero Paragraph
                buttons:
                  - bold
                  - italic
                  - link    
          Text:
            type: fields
            fields:
              line:
                type: line
              page-text:
                type: textarea
                label: Page text
                size: large
          Photos:
            type: fields
            fields:
              line2:
                type: line
              gallery:
                type: files
                query: page.images
                label: Supporting Photos
                layout: cards
                image:
                  ratio: 1/1

      sidebar:
        width: 1/3
        sections:
          MainHeroImage:
            type: files
            query: page.images
            label: Hero Image
            layout: cards
            size: small
            max: 1
            image:
              ratio: 16/9
              cover: true
              
  seo:
    label: SEO
    icon: search
    extends: components/seo

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [April 18, 2024, 10:59am UTC](https://forum.getkirby.com/t/show-a-single-image-from-a-different-section/31396/4 "2024-04-18T10:59:43Z")

</div>

> [@Martagnan](#):
>
> ```auto
> sections:
> MainHeroImage:
> type: files
> 
> ```

Exactly as I assumed. Your MainHeroImage is a files section, not a files field. Therefore, it is not stored in the content file. And getting the image belonging to this section will be difficult, as there are other images in the page and this section has no particular file template attached.

So two options here: Assign a template to the section, e.g. heroimage, then you can find that file via the template.

Or turn the section into a field.

```auto
 sections:
   herosection:
     type: fields
     fields:
       MainHeroImage:
         type: files
         # other setting

```

---

<div class="post-metadata">

**Author:** ![Martagnan](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/martagnan/32/14691_2.png) [@Martagnan](https://forum.getkirby.com/u/Martagnan)\
**Post date:** [April 18, 2024, 12:44pm UTC](https://forum.getkirby.com/t/show-a-single-image-from-a-different-section/31396/5 "2024-04-18T12:44:04Z")

</div>

Thank you for your fast response and solution!
