How to extract the Image parameter from a local md file

Hi All,

I am trying to build a shortcode which would display the image by extracting the image parameter from a separate md file.

The code I could come up with is as below. I know this is wrong and it’s not working, but just trying to illustrate what I am trying to achieve.

<img src="{{ readFile "/content/english/folder1/" }}.Params.image">

I want to read the image parameter in and use it to display the image for the shortcode.

Note that I want to read the parameters of and use it to display an image within a separate file eg

Please help with code. I am relatively new to this.




{{< foo "/english/folder1/testfile" >}}


{{- with .Get 0 -}}
  {{- $otherPage := $.Site.GetPage . -}}
  {{- with $otherPage.Params.image -}}
    <img alt="" src="{{ . }}">
  {{- end -}}
{{- else -}}
  {{- errorf "The '%s' shortcode requires one positional parameter, the path to the other page. See %s" .Name .Position -}}
{{- end -}}

Thank You so much. It works perfectly :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.