{{ $url := urls.Parse .Destination }}
<!-- need to parse this "width=100px&height=500px)" to get the width and height value-->
{{ $url.RawQuery }}
<!-- Output clean image destination url without the ?query params -->
{{ $cleanURL := .Destination | strings.TrimSuffix (print "?" $url.RawQuery) }}
I use explicit height in my CSS (which I load blocking in the head). This prevents page jump. Not being able to load shortcodes AND not being able to set the height in the CSS is a rare situation. I like your idea @pamubay.
I’m relatively new to Hugo and all my projects so far I have been using images retrieved using resources.Get so getting things like width & height wasn’t an issue and this is the first time I will be working with a lot of images directly from the markdown.
Some of the markdown will be in strings so I will use the principles in @pamubay approach and do some regex to set the width and height as render hooks and shortcodes aren’t applicable.
@jhvanderschee I agree page jumps can be awful so apart from bad practice of no explicit width & height it’s a problem in other ways. I may also see what I can do with CSS.
Yes you are correct but I don’t anticipate many images on each page and I’m fairly confident it should all load quite quickly so shouldn’t be a big issue. Thanks
I think I will bake the resolution into the image filename rather than having it as a query string and do the same approach you describe. As I said this is a good idea but in my situation having it baked into the filename is better for me. I’ll make sure all images have this specific format but of course the render hook will have error handling if the pattern doesn’t match.