How to get the path to the assets directory without hardcoding?

That’s fine :grinning:. Thank you very much @jmooring!

Without os.Stat I can also retreive other image information (e.g. width, height and file name). So, I udated my shortcode for responsive images from the default assets directory (/layouts/shortcodes/responsive-image-assets.html) :

{{ $altText := .Get "alt"}}
{{ $caption := .Get "caption"}}
{{ $linkTitle := .Get "link-title"}}
{{ $image := resources.Get (.Get "src") }}


{{ $filesize := len $image.Content }}

{{ with $image }}
{{ with $caption }}
<figure>
{{ end }}
    <a href="{{.RelPermalink}}" {{ with $linkTitle }} title="{{ $linkTitle }} ({{ path.Base $image.Name }}, {{ $image.Width }} x {{ $image.Height }} px, {{div (int $filesize) 1024 }} KB)" {{ end }} target="_blank">
        <img
            srcset="
            {{ if ge $image.Width 320 }}
                {{ (.Resize "320x").RelPermalink }} 320w,
            {{ end }} 
            {{ if ge $image.Width 430 }}
                {{ (.Resize "430x").RelPermalink }} 430w,
            {{ end }}
            {{ if ge $image.Width 860 }}
                {{ (.Resize "860x").RelPermalink }} 860w,
            {{ end }}
            {{ if ge $image.Width 1720 }}
                {{ (.Resize "1720x").RelPermalink }} 1720w
            {{ end }}"           
            sizes="(max-width: 900px) calc(100vw - 4rem), 860px"
            src="
            {{ if ge $image.Width 1720 }} 
                {{ (.Resize "860x").RelPermalink }}
            {{ end }} 
            " alt="{{$altText}}"/>
    </a>
    {{ with $caption }}
    <figcaption>{{ $caption }}</figcaption>
    </figure>
    {{ end }}
{{ end }} 

Example for using the shortcode (for image stored in /assets/images/):

{{< responsive-image-assets src="/images/kuchen-2000.jpg" alt="Gugelhupf" caption="Gugenhupf" link-title="Originalbild in neuem Fenster öffnen" >}}