Hello
I try to display my first image but i can’t do it.
I use the the hyde theme
So i put a shortcode in
layouts\shortcodes\img.html
<!-- layouts/shortcodes/img.html -->
<img src="/uploads/{{ .Get " src" }}" alt="{{ .Get " alt" }}">
I got an image in
static/uploads/2023/black.jpg
And i try to display the image in a post localised in
content/posts/2023
And this is a part of my posts
---
title: "2023 08 06 a Sample Post"
date: 2023-08-06T16:54:24+02:00
draft: true
---
{{< img src="/uploads/2023/black.jpg" alt="Blue is also the coolest color!" >}}
Bonjour
Do you know why i can’t see my image ?
Why do you call your shortcode with the complete image path? It will then output
<img src="/uploads/uploads/2023/black.jpg" alt=...>
And why do you put blanks before the parameters in your .Get calls?
What do your browser developer tools tell you about the img element in the generated HTML?
Hi
I change the path
{{< img src="/2023/black.jpg" alt="Blue is also the coolest color!" >}}
This is what i get on my browser developer tools
<img src="/uploads/" alt="">
And the blank before the parameters in my .Get it’s because i got a Auto Indent.
Do you know a Visual studio code plugin that resolve this auto indent problem ?
The space is part of your problem. I use VS Code and I don’t see that happening here.
i change my extension file from .html to .gohmtml now is okay
thanks