Site icon Hip-Hop Website Design and Development

Can’t retrieve <enclosure> element with WordPress default @fetch_rss();

I’m trying to fetch and display items from another WordPress site’s RSS feed.

I have everything working and have done this sort of thing before, but this time, the RSS feed I’m fetching has it’s ‘featured’ images like so:

<enclosure url="https://cdn.canpl.ca/app/uploads/cpl/2022/01/10102550/DJC07504-e1641828489467-730x365.jpg" length="0" type="image/jpeg"/>

Now, I know exactly what I need to do with that once it’s returned, not a problem at all… …but then WordPress MagpieRSS decides to do its thing…

When I fetch the feed using:

$rss_feed       = @fetch_rss( $rss_src );

I don’t actually get the <enclosure> tag returned. So it looks as though WP is stripping that out.

The var_dump($rss_feed) shows:

object(MagpieRSS)#1266 (20) { ["parser"]=> NULL ["current_item"]=> array(0) { } ["items"]=> array(15) { [0]=> array(9) { ["points"]=> string(2) "10" ["title"]=> string(97) "WATCH: CPL Commissioner David Clanachan’s exclusive interview following Monday’s announcement" ["link"]=> string(112) "https://canpl.ca/link/watch-cpl-commissioner-david-clanachans-exclusive-interview-following-mondays-announcement" ["pubdate"]=> string(31) "Mon, 10 Jan 2022 17:33:08 +0000" ["guid"]=> string(112) "https://canpl.ca/link/watch-cpl-commissioner-david-clanachans-exclusive-interview-following-mondays-announcement" ["description"]=> string(20) " " ["content"]=> array(1) { ["encoded"]=> string(20) " " } ["summary"]=> string(20) " " ["atom_content"]=> string(20) " " } [1]=> array(9) { ["points"]=> string(2) "10" ["title"]=> string(124) "Commissioner David Clanachan Awarded Exclusive CPL Rights to Windsor/Essex County and to Step Down as First CPL Commissioner" ["link"]=> string(148) "https://canpl.ca/article/commissioner-david-clanachan-awarded-exclusive-cpl-rights-to-windsoressex-county-and-to-step-down-as-first-cpl-commissioner" ["pubdate"]=> string(31) "Mon, 10 Jan 2022 17:15:02 +0000" ["guid"]=> string(148) "https://canpl.ca/article/commissioner-david-clanachan-awarded-exclusive-cpl-rights-to-windsoressex-county-and-to-step-down-as-first-cpl-commissioner" ["description"]=> string(20) " " ["content"]=> array(1) { ["encoded"]=> string(9517) "

Genuinely not sure where else to turn. I did find a MagpieRSS HotFix plugin, which actually just replaces the entire MagpieRSS functionality in WordPress, and was going to look at what was being done, but that plugin hasn’t been updated in 13 years, so not sure how reliable that code is.

Anyone have any idea how I can get WordPress to stop stripping out the <enclosure> tag?