Stopping error "calling Width: this method is only available for image resources"

Is it possible to stop

Error: Error building site:
execute of template failed: template: _default/_markup/render-image.html:22:13:
executing "_default/_markup/render-image.html" at <$img.Width>:
error calling Width: this method is only available for image resources
Built in 1534 ms

or change it just a warning ?

I am trying to use display (some) videos through the tag as it’s now possible on safari, chromium too I think. Problem is this error, which serves no purpose here since I laced the renderhook with apropriate conditionals so that $img.Width is never called if $img is a video ressource.

It’s not a custom error case so no custom error ID, nor a case ofresources.GetRemote so I’m not sure .Err would match anything.`

Could you share more details about the code?

If the $img.Width isn’t really being called, the error shouldn’t exist.

Yeah you’re right I had forgotten the “not” in defining $IsVideo. Stupid me.
Correcting that, the background stopped working (??) and a tabs shortcode calls I had inlined for the lulz, stopped working, output a <pre> tag instead of the wanted <img> (weirder !), so I de-inlined them and the background went back to normal somehow, though not immediately.
It seems <img> with mp4 doesn’t work on chromium, nor firefox, but I would appreciate if you could test, see if it’s not my build or system.
I changed to a normal <video> (still called with ![]()) which is no good because I have it loop and autostart, but this tag doesn’t do lazy load apparently, so instead of loading and turning on when on screen (ideally, stopping too when off screen), it preloads hence takes two more seconds charging the page, which I don’t like at all, because I’m nothing if not a perfectionist… even though the viewing experience doesn’t really get impacted if I’m honest.

I see. To be honest, I didn’t understand the whole video with <img> tag situation.

I’m assuming you’re trying to mimic the GIF experience with videos? And instead of creating a shortcode just for that, you decided to use the image renderhook.

Anyway, that’s another issue, out of the scope of Hugo. I would recommend you read this: Lazy loading video.

Yay… Javascript…
The point of an <img> video feature (from my perspective) is to use the native <img> lazy loading capability.

Yes, because shortcodes are ugly. Markdown doesn’t natively acknowledge videos (beside injecting html), but such tricks make it as if it did. There would be little point having a separate syntax for videos imho, let us improve custom attributes instead and the need for shortcodes will be significantly alleviated. I’m all for intelligent systems that figures out obvious needs on it own.

That said, I’ll see if the js code is easy to integrate :wink: