HowTo: Use PicLens and other MediaRSS Clients for your own Website (create MediaRSS with LINQ to XML)

This blogpost is related to the "RSS XLINQ" post – but this time the result will be cooler ;) .

About this post
This post is about the "MediaRSS" standard and how you can use it for your own website. If you have never heard of it – never mind. But maybe you have heard of a really cool Firefox Plugin called "PicLens".

image 

"PicLens"?
"PicLens" is a incredible surface for some internet services, like YouTube, Google picture search, Flickr or Amazon:

image
This is the Amazon-Surface:

image

Media RSS
The Piclens guys have implemented the "MediaRSS" standard – that means: Each site with an MediaRSS can be viewed in Piclens. 
If you are a webmaster, you should take a look at this site. We created in the last post an RSS feed with XLinq – MediaRSS shouldn´t be much harder to code:

XLINQ

We have the same project files – only the RSS generation must be changed:

        XNamespace media = "http://search.yahoo.com/mrss";
        XNamespace atom = "http://www.w3.org/2005/Atom";
        public void ProcessRequest(HttpContext context)
        {

            XDocument document = new XDocument(
                                    new XDeclaration("1.0", "utf-8", "yes"),
                                    new XElement("rss",
                                        new XAttribute("version", "2.0"),
                                        new XAttribute(XNamespace.Xmlns + "media", media),
                                        new XAttribute(XNamespace.Xmlns + "atom", atom),
                                        new XElement("channel", this.CreateElements())
                                       ));

            context.Response.ContentType = "text/xml";
            document.Save(context.Response.Output);
            context.Response.End();
        }

        private IEnumerable<XElement> CreateElements()
        {
            List<XElement> list = new List<XElement>();

            for(int i = 1; i < 100; i++)
            {
                XElement itemElement = new XElement("item",
                                            new XElement("title", i),
                                            new XElement("link", "Code-Inside.de"),
                                            new XElement(media + "thumbnail",
                                                new XAttribute("url", "http://code-inside.de/blog/wp-content/uploads/image-thumb" + i + ".png")),
                                            new XElement(media + "content",
                                                new XAttribute("url", "http://code-inside.de/blog/wp-content/uploads/image-thumb" + i + ".png"))
                                       );
                list.Add(itemElement);
            }

            return list;
        }

This time we need 2 XNamespaces – "media" and "atom" are need to create a valid MediaRSS:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss" xmlns:atom="http://www.w3.org/2005/Atom">
...
</rss>

These namespaces must be added by using the XAttribute class. The syntax is in my point of view a bit to complex, but I didn´t  find a better way. 

The source code above is everything you need to create a "simple" MediaRSS – there are some other elements supported by piclens – look at the Guide for more information.

Result:

We created the RSS auto-detection in the last blogpost. Piclens can now find the MediaRSS elements and show us the pictures on the "Wall" (the Piclens-Button glow if it find a MediaRSS Feed on the site) :

image

image 
If you have several pictures on your site – publish a MediaRSS Feed. It´s very easy and it´s an open standard (Specification @ Yahoo) – Piclens is just one MediaRSS Client (but today the client with the best surface).

[ Download Source Code ]

PS: I use my german blog as the picture source – please don´t abuse this example (traffic :( ) ;)

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

About the author

Written by Code Inside Team

Currently there is no additional info about this author.

Comment on this post

Recent Posts

  • Windows Phone Fonts & what if Visual Studio lies

    Today I was confronted with a little Problem: my Windows Phone App refused to show me the Font I choose – also other thinks didn’t work. Although the Visual Studio Designer did show the Fonts: Unfortunately there isn’t much left in the Emulator: Reason for this: Windows Phone doesn’t include all the typos Windows does ...

  • Json-Online-Tools: Viewer & Json2Csharp generator

      Wherever APIs are mentioned the JSON format I not far away. Since I’m using two tools regularly I would like to introduce you to them. JSON Viewer If you only see the JSON-Text you are usually not able to see the structure. With the help of JSON Viewer you can have an easy overview: ...

  • Windows Phone SDK & „System“-Icons

      Although the Metro Design focuses a lot on Typography Icons are still quite important. If you install Windows Phone SDK you will receive 36 Icons. You can find them here: C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Icons Unfortunately many Icons you might know from the common applications are not integrated. Pedro Lamas extracted 99 additional Icons ...

  • image1830-570x194.png
    How can I figure out if my ADFS 2.0 works?

      I was working with ADFS 2.0 (“Active Directory Federation Services”) for a while when this simple question crossed my mind: How can I figure out if the connection between ADFS and AD “works”? Here is a simple test… What is ADFS? If you need some “position of trusts” beneath the AD-boarders you choose an ...

  • Subdomain vs. Subdirectory

      Better blog.mydomain.com or mydomain.com/blog? Good question! If got asked this question again via Twitter on the weekend so therefore I decide to share my experiences:   Choose a subdomain, if…. - You plan to offer “different services” which are “logical separated” on one domain - You are able to influence the subdomains without much ...

Support us