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

Modify embedded figure shortcode to look for page resource #12245

Closed
jmooring opened this issue Mar 14, 2024 · 1 comment · Fixed by #12246
Closed

Modify embedded figure shortcode to look for page resource #12245

jmooring opened this issue Mar 14, 2024 · 1 comment · Fixed by #12246

Comments

@jmooring
Copy link
Member

jmooring commented Mar 14, 2024

Reference: #12244

With a shared page resource (e.g., image) on a multilingual single-host site, we do not (by default) duplicate the resource for each language, as designed. In this configuration we automatically enable an embedded image render hook to handle markdown destinations, but the embedded figure shortcode does not use the same logic, resulting in broken images.

We need to do this:

  {{- $u := urls.Parse (.Get "src") -}}
  {{- $src := $u.String -}}
  {{- if not $u.IsAbs -}}
    {{- with or (.Page.Resources.Get $u.Path) (resources.Get $u.Path) -}}
      {{- $src = .RelPermalink -}}
    {{- end -}}
  {{- end -}}

This should be safe regardless of site configuration. We're not touching external destinations, and we fall back to the original value if we can't find a page resource or global resource.

@jmooring jmooring changed the title Modify embedded figure shortcode to look for local page resource Modify embedded figure shortcode to look for page resource Mar 14, 2024
@jmooring jmooring self-assigned this Mar 14, 2024
jmooring added a commit to jmooring/hugo that referenced this issue Mar 14, 2024
jmooring added a commit to jmooring/hugo that referenced this issue Mar 14, 2024
@bep bep closed this as completed in 48a0fea Mar 14, 2024
evgeny-kim added a commit to evgeny-kim/hugo-theme-jane that referenced this issue Apr 2, 2024
  Look for page resource or global resource (gohugoio/hugo#12245)
* Add fingerprint to the resources
* Preserve original hugo-easy-gallery logic
Copy link

github-actions bot commented Apr 5, 2024

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 Apr 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant