I have a Syndication Feed. When serializing using Rss20FeedFormatter I get xmlns:cf and xmlns:cfi namespaces declared in the xml. The media element remains inline.
<media:thumbnail media:url="http://arwen.palantir.za:8080/signate/thumbnail/dXVpZDoxNjlkMzIyOS0zYjk5LTQ2NDctOTc5MS00OTJiYmJmNGM0MTkvUEdTMDkwMC5QREY=" media:width="200" media:height="200" xmlns="http://www.w3.org/2005/Atom" xmlns:a="http://search.yahoo.com/mrss" xmlns:media="http://search.yahoo.com/mrss"></media:thumbnail>
I am sure this is why the thumbnails are not displaying correctly. How do I add media:thumbnail and have it work properly. I am using Windows 7 search to view, so it definitely supports the thumbnail.
I would like the media declared in the xml header as it should be.
This is my code:
item.ElementExtensions.Add(
new XElement(mrss + "thumbnail",
new XAttribute(XNamespace.Xmlns + "media", mrss),
new XAttribute(mrss + "url", url + Convert.ToBase64String(Encoding.ASCII.GetBytes(item.Id)))开发者_运维技巧,
new XAttribute(mrss + "width", 200),
new XAttribute(mrss + "height", 200)
).CreateReader());
You do certainly need to add the correct namespace as Cragly explains, but here's how to create a proper media:thumbnail element:
XNamespace _yahooMediaNamespace = "http://search.yahoo.com/mrss/";
// Result is a SyndicationItem
result.ElementExtensions.Add(
new SyndicationElementExtension(
new XElement(
_yahooMediaNamespace + "thumbnail",
new XAttribute("url", "http://www.example.com/image.jpg")
)
)
);
I think this is a case of you just needing to declare your feed namespaces before you use them. I provided an answer on another question which shows how to declare the namespace and then use it in an ElementExtension.
精彩评论