Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR change? What problem does it solve?
This PR is a step towards solving issue 891. This is how I dealt with issue #891 on my personal website, so I thought I'd pass it back upstream.
Most RSS aggregators I've played with seem to pull image data for a post from either the
<enclosure />
tag, or from the first image referenced in an article. This PR makes the cover image visible in both of these places.Was the change discussed in an issue or in the Discussions before?
It offers a preliminary (though, imperfect) solution to #891 by adding a given post's
.Params.cover.image
to the RSS feed's<enclosure />
, and into the body/content of the post. (Assuming the.Params.cover.image
variable is set; otherwise, it defaults to the current functionality)This code works on all the RSS aggregators I tested it on, but there are a couple problems with it that are beyond my current Go/Hugo knowledge.
length
attribute, with the length of the media file in bytes. Yihan Wu outlines a solution to this, but I kept getting aerror calling readFile: file does not exist hugo
whenever I tried to implement that solution. I gave a several-hour effort to try to figure it out, but alas Hugo/Go works differently than I'm used to coding in, so I couldn't crack it. All RSS readers I tried seemed to work fine with the code as I've written it, so I'm submitting it even though this "required" attribute is missing.type
in the<enclosure>
tag is hard-coded asjpeg
. Ideally, this would take the file extension (or mime type?) of the media file, and dynamically change the type to webp/png/whatever, but I also couldn't figure that out in the time I gave myself for this task. All my personal site images are JPEGs, so it's been fine for me. Also, this PR still seemed to work fine when I tested it on a few RSS readers with WEBP images, even though strictly speaking the syntax is incorrectly saying those images are JPEG. Ideally, the mime type would be dynamically changed, but it seems to be working for now in all the places I've tested.PR Checklist
(☝🏽 to the best of my current abilities and knowledge)