Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IsBlock to the image render hook context #10494

Closed
bep opened this issue Dec 3, 2022 · 2 comments
Closed

Add IsBlock to the image render hook context #10494

bep opened this issue Dec 3, 2022 · 2 comments
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Dec 3, 2022

While working on #10493 I see that the template somehow needs to know if we're inline or not.

In HTML

  • img is an inline element.
  • figure is a block element.

Mot images in Markdown files is put in their own paragraphs and can be wrapped with a figure. But it's not possible to make that into a general rule.

Not sure how easy this is, however.

@bep bep added the Enhancement label Dec 3, 2022
@bep bep self-assigned this Dec 3, 2022
@bep bep added this to the v0.108.0 milestone Dec 3, 2022
@pamubay
Copy link

pamubay commented Dec 4, 2022

This is nice, can we also do it for render link? My usage is i want paragraph that contains only a link to render block element.

Hello world

[Hugo Video](https://youtu.be/0RKpf3rK57I)

Hello World

The link will render youtube embedded iframe.

bep added a commit to bep/hugo that referenced this issue Dec 4, 2022
* Removes any surrounding paragraph nodes
* And transfers any attributes from the surrounding paragraph down to the image node
* Adds a new IsBlock field to the link context passed to the render hooks, only set for images.

IsBlock is set to true if the image's parent node has only one child.

Closes gohugoio#8362
Fixes gohugoio#10492
Fixes gohugoio#10494
bep added a commit to bep/hugo that referenced this issue Dec 4, 2022
* Removes any surrounding paragraph nodes
* And transfers any attributes from the surrounding paragraph down to the image node
* Adds a new IsBlock field to the link context passed to the render hooks, only set for images.

IsBlock is set to true if `wrapStandAloneImageWithinParagraph = false` and  the image's parent node has only one child.

Closes gohugoio#8362
Fixes gohugoio#10492
Fixes gohugoio#10494
bep added a commit to bep/hugo that referenced this issue Dec 5, 2022
* Removes any surrounding paragraph nodes
* And transfers any attributes from the surrounding paragraph down to the image node
* Adds IsBlock and Ordinal (zero based) field to the image context passed to the image render hooks

IsBlock is set to true if `wrapStandAloneImageWithinParagraph = false` and  the image's parent node has only one child.

Closes gohugoio#8362
Fixes gohugoio#10492
Fixes gohugoio#10494
Fixes gohugoio#10501
@bep bep closed this as completed in 63126c6 Dec 5, 2022
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants