.Ordinal in image renderhook

I see an .Ordinal in the image render hook documentation (render hook, not a shortcode). When I debug it, though, I get NIL. Are there any requirements to have an ordinal or do I misunderstand it? I would expect the first image to show 0, the second to show 1, etc…

Selection_311x31_20240409-19:08:31

Selection_462x251_20240409-19:07:57

Your debug blog looks like it’s reporting the values of a link, not an image.

An image render hook will never report nil for Attributes, Ordinal, or IsBlock.

Thanks, I will check that…

But I can’t think of a way to make that happen, because within a link render hook you’ll get this message if you call .Ordinal:

can’t evaluate field Ordinal in type goldmark.linkContext

The actual debug line (printf with %#v I think) brings this:

goldmark.imageLinkContext{linkContext:goldmark.linkContext{page:(*hugolib.pageForRenderHooks)(0xc0244fd740), destination:"input.jpg", title:"title", text:"input", plainText:"input", AttributesHolder:(*attributes.AttributesHolder)(0xc03b6fa960)}, ordinal:0, isBlock:false}

So I think my debugging partial is somewhere wrong about the NIL (in more than one place). My own fault :slight_smile: both 0 and false should somehow result in int and bool.

Thank you for your help!

1 Like

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