Skip to content

Preserve multiple media:content entries - #344

Merged
prof18 merged 2 commits into
prof18:masterfrom
Xiryl:fix/mediacontent
Nov 8, 2026
Merged

prof18 merged 2 commits into
prof18:masterfrom
Xiryl:fix/mediacontent

Conversation

@Xiryl

@Xiryl Xiryl commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Hi!

This PR preserves all Media RSS <media:content> elements for each item.

RssItem now exposes:

val rawMediaContents: List<RawMediaContent>

Each entry includes url, type, medium, width, and height.

The existing rawMediaContent property is kept for compatibility and returns the first entry.

Why

Feeds can publish several renditions of the same image. For example, The Guardian RSS feed provides the same article image at 140px, 460px, and 700px.

Example XML from The Guardian feed
<item>
<title>The extraordinary untold story of Freddie Mercury: Mary Austin on her best friend – and love of her life</title>
<link>https://www.theguardian.com/music/2026/sep/01/freddie-mercury-lover-mary-austin-interview</link>
<description><p>He was Queen’s flamboyant frontman. She was his shy girlfriend, dreaming of marriage until they both realised he preferred men. Thirty-five years after his death, in the week he would have turned 80, Mary Austin talks about their unbreakable bond</p><p>There were four silver trunks in Mary Austin’s attic that she packed in the mid-1980s and hadn’t opened since. It was too painful. Almost 40 years on, in 2022, she opened one. It was crammed with lyrics from songs written by Freddie Mercury – Don’t Stop Me Now, Killer Queen, We Are the Champions and, of course, Bohemian Rhapsody. She shut the case. It was still too painful.</p><p>“To say I was overwhelmed is an understatement,” she says. “I couldn’t look at the lyrics. I felt as I did when I originally packed them – that they were his personal belongings and I was being offered an opportunity to delve into them, and I couldn’t do that.” Eventually she asked her two sons to sift through the treasures on her behalf.</p> <a href="/?url=https%3A%2F%2Fwww.theguardian.com%2Fmusic%2F2026%2Fsep%2F01%2Ffreddie-mercury-lover-mary-austin-interview">Continue reading...</a></description>
<category domain="https://www.theguardian.com/music/freddie-mercury">Freddie Mercury</category>
<category domain="https://www.theguardian.com/music/music">Music</category>
<category domain="https://www.theguardian.com/culture/culture">Culture</category>
<category domain="https://www.theguardian.com/music/popandrock">Pop and rock</category>
<category domain="https://www.theguardian.com/society/aids-and-hiv">Aids and HIV</category>
<category domain="https://www.theguardian.com/music/queen">Queen</category>
<pubDate>Tue, 01 Sep 2026 04:00:46 GMT</pubDate>
<guid>https://www.theguardian.com/music/2026/sep/01/freddie-mercury-lover-mary-austin-interview</guid>
<media:content width="140" url="https://i.guim.co.uk/img/media/88ed2dce39284e7e68020ba10a16f9e8adfb4145/0_618_3639_2912/master/3639.jpg?width=140&quality=85&auto=format&fit=max&s=f91ebca2c26db3943f55f178faeda4b5">
<media:credit scheme="urn:ebu">Photograph: Courtesy of Mary Austin</media:credit>
</media:content>
<media:content width="460" url="https://i.guim.co.uk/img/media/88ed2dce39284e7e68020ba10a16f9e8adfb4145/0_618_3639_2912/master/3639.jpg?width=460&quality=85&auto=format&fit=max&s=3301b1bd28d805cc0610b6407e0b9d28">
<media:credit scheme="urn:ebu">Photograph: Courtesy of Mary Austin</media:credit>
</media:content>
<media:content width="700" url="https://i.guim.co.uk/img/media/88ed2dce39284e7e68020ba10a16f9e8adfb4145/0_618_3639_2912/master/3639.jpg?width=700&quality=85&auto=format&fit=max&s=24d61f9a69f184d5d1f76a58cf5ca810">
<media:credit scheme="urn:ebu">Photograph: Courtesy of Mary Austin</media:credit>
</media:content>
<dc:creator>Simon Hattenstone</dc:creator>
<dc:date>2026-09-01T04:00:46Z</dc:date>
</item>

Previously, only the first rendition was retained, so consumers could only access the 140px image. With rawMediaContents, they can choose the best variant:

val largestImage = item.rawMediaContents.maxByOrNull { it.width ?: 0 }

The change is implemented on Android, JVM, Apple, JS, and Wasm, with test coverage for multiple image sizes.

@Xiryl
Xiryl marked this pull request as ready for review September 1, 2026 10:43
@prof18

prof18 commented Nov 8, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T09:39:26.836674Z 3440faa Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3440faae7c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@prof18

prof18 commented Nov 8, 2026

Copy link
Copy Markdown
Owner

@Xiryl thank you so much for the contributions, it was a missed point.

And so sorry for the late reply, I kinda missed this 😓

I'll do some improv and cut a release soon

…media

rawMediaContent is now a computed accessor over the first entry of
rawMediaContents, so copy() and direct construction can no longer leave the
two out of sync. media:content elements that carry only width/height are
kept instead of being dropped.
@prof18
prof18 merged commit 88463e4 into prof18:master Nov 8, 2026
99 of 110 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants