Need help please. I am trying to build an rss-based feed in django. But I am finding media:content (url, medium, height and width) to be tricky.
I have looked and looked, and ended up with this:
class CustomFeed(Rss201rev2Feed): def add_item_elements(self, handler, item): super().add_item_elements(handler, item) handler.addQuickElement("image", item["image"])class Rss(Feed): feed_type = CustomFeed title = "#Title of the item" link = "/feeds/" description = "#Description of the item" def item_extra_kwargs(self, item): img_url = item.image.medium.url request_url = self.request.build_absolute_uri('/')[:-1] image_url_abs = f"{request_url}{img_url}" return {'image': image_url_abs }
But this gives me the image as standalone in the rss feed:
<image>https://www.url.com/image.jpg</image>
i badly need the code to return this:
<media:content url="https://www.url.com/image.jpg" medium="image" height="640" width="362"/>
please help.