Skip to content

Preserve multiple media:content entries - #344

Open
Xiryl wants to merge 1 commit into
prof18:masterfrom
Xiryl:fix/mediacontent
Open

Preserve multiple media:content entries#344
Xiryl wants to merge 1 commit 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="https://www.theguardian.com/music/2026/sep/01/freddie-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
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.

1 participant