Skip to content
New issue

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

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

Already on GitHub? # to your account

Full/absolute URL for image links in RSS feeds #8200

Closed
patdavid opened this issue Feb 2, 2021 · 4 comments
Closed

Full/absolute URL for image links in RSS feeds #8200

patdavid opened this issue Feb 2, 2021 · 4 comments
Labels

Comments

@patdavid
Copy link

patdavid commented Feb 2, 2021

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.80.0/extended windows/amd64 BuildDate: unknown

Does this issue reproduce with the latest release?

Yes

Issue

When generating RSS feeds any links in the content that use a relative (local) path to the image keep them:

With content as:

├── My New Post
│       │   ├── index.md
│       │   ├── image.png

in index.md:

...
<img src="image.png">
...

This works perfectly well for actual post content on the website, but the RSS feed maintains the same img source (not using an absolute path). This breaks the RSS rendering of the content in some feed readers.

I was hoping to perhaps fix this with a regex replace in the RSS template, but re2 in go doesn't support forward/negative lookaheads to deal with this (ie: not replacing src path if it's already absolute).

Any ideas or thoughts about pushing absolute src paths for images in RSS feeds?

@zerovip
Copy link

zerovip commented Feb 3, 2021

Render hooks should help, but seems that there is a #8176 (?)

Edit: Thank you for explaining, I have no idea then.

@patdavid
Copy link
Author

patdavid commented Feb 3, 2021

We've had limited success with layouts/_default/_markup/render-image.html and adding a full URL there (this does get picked up by the RSS template as part of {{ .Content | html }}.

However, this doesn't seem to work for <figure> <img> ... - my guess is that using the figure shortcode skips(ish) the markdown conversion for the render-image.

@stereobooster
Copy link

AFAIK Render hooks only work for markdown, but not for HTML tags or shortcodes

this works:

![alt](./path.jpg)

this doesn't

<img src="" />
{{< img src="" >}}

@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 Jan 23, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants