# Why using images placed inside bundle does not work in partial

**URL:** <https://discourse.gohugo.io/t/why-using-images-placed-inside-bundle-does-not-work-in-partial/29702>\
**Category:** support\
**Created:** [November 29, 2020, 9:05pm UTC](https://discourse.gohugo.io/t/why-using-images-placed-inside-bundle-does-not-work-in-partial/29702 "2020-11-29T21:05:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![miloskroulik](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/miloskroulik/32/10673_2.png) [@miloskroulik](https://discourse.gohugo.io/u/miloskroulik)\
**Post date:** [November 29, 2020, 9:05pm UTC](https://discourse.gohugo.io/t/why-using-images-placed-inside-bundle-does-not-work-in-partial/29702/1 "2020-11-29T21:05:41Z")

</div>

I’m trying to make image processing work with [forestry.io](http://forestry.io) and use component-like partials at the same time. So I’m trying to make it work like this:

- in my `index.html` template, I’m rendering list of content

```auto
{{ range first 2 (where site.RegularPages "Type" "in" "featured") }}
   {{ .Render "summary" }}
{{ end }}

```

- in `summary.html` template, I’m including my “component” partial like this

```auto
{{ partial "components/card3" (dict "context" . "imgwidth" "50") }}

```

- in my `card3.html` template, I’m trying to render an image like this:

```auto
{{ with .context.Params.image }}
    {{ $imageResource := ($.Site.GetPage "section" "uploads").Resources.GetMatch (strings.TrimPrefix "/uploads/" . ) }}
    {{ $resized := $imageResource.Fill "200x200" }}
    <img src="{{ $resized.RelPermalink }}" />
{{ end }}

```

This doesn’t work (`src` is empty) even when `.context.Params.image`  
correctly returns name of image linked in the frontmatter

Interestingly, if I use my `summary.html` template directly like this:

```auto
{{ with .Params.image }}
    {{ $imageResource := ($.Site.GetPage "section" "uploads").Resources.GetMatch (strings.TrimPrefix "/uploads/" . ) }}
    {{ $resized := $imageResource.Fill "200x200" }}
    <img src="{{ $resized.RelPermalink }}" />
{{ end }}

```

it seems to be working fine. What am I doing wrong here?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [November 29, 2020, 10:08pm UTC](https://discourse.gohugo.io/t/why-using-images-placed-inside-bundle-does-not-work-in-partial/29702/3 "2020-11-29T22:08:47Z")

</div>

In card3.html replace `$.Site.GetPage` with `site.GetPage`.

---

<div class="post-metadata">

**Author:** ![miloskroulik](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/miloskroulik/32/10673_2.png) [@miloskroulik](https://discourse.gohugo.io/u/miloskroulik)\
**Post date:** [November 30, 2020, 8:24am UTC](https://discourse.gohugo.io/t/why-using-images-placed-inside-bundle-does-not-work-in-partial/29702/4 "2020-11-30T08:24:58Z")

</div>

Thanks, this works fine. Now I just need to understand why…

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [November 30, 2020, 9:57am UTC](https://discourse.gohugo.io/t/why-using-images-placed-inside-bundle-does-not-work-in-partial/29702/5 "2020-11-30T09:57:48Z")

</div>

`$` is the global context. “Global” from within the partial is the context that you pass to it, ie:

```auto
(dict "context" . "imgwidth" "50")

```

… which does not have `.Site`.

ref: [https://gohugo.io/variables/site/#get-the-site-object-from-a-partial](https://gohugo.io/variables/site/#get-the-site-object-from-a-partial)

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [November 30, 2020, 11:52am UTC](https://discourse.gohugo.io/t/why-using-images-placed-inside-bundle-does-not-work-in-partial/29702/6 "2020-11-30T11:52:46Z")

</div>

In your example, either of these will work:

```auto
site.GetPage
$.context.Site.GetPage

```

`.Site` is available from `.Page`, and at the root context of your partial `.Page` is represented by `.context`.

`$` --\> root context of partial  
`.context` --\> `.Page`
