flickr net api: DoesLargeExist and DoesMediumExist always return false

Topics: Project Management Forum
Jan 22, 2013 at 8:35 AM
Edited Jan 22, 2013 at 8:36 AM

Hi everyone,

I have a problem with Flickr API. I would like to get the largest version of an image on flickr.

At first everything is OK with the following source code:

 

if (!string.IsNullOrEmpty(photo.OriginalUrl))
                    {
                        BiggestVersionUrl = photo.OriginalUrl;
                    }
                    else if (!string.IsNullOrEmpty(photo.LargeUrl)
                    {
                        BiggestVersionUrl = photo.LargeUrl;
                    }
                    else if (!string.IsNullOrEmpty(photo.MediumUrl)
                    {
                        BiggestVersionUrl = photo.MediumUrl;
                    }
                    else if (!string.IsNullOrEmpty(photo.SmallUrl))
                    {
                        BiggestVersionUrl = photo.SmallUrl;
                    }

But with some flickr accounts has photos which were uploaded a long time ago, it return an image with the content is
"The image is unavaiable".

Then I updated my code like this:

if (!string.IsNullOrEmpty(photo.OriginalUrl))
                    {
                        BiggestVersionUrl = photo.OriginalUrl;
                    }
                    else if (!string.IsNullOrEmpty(photo.LargeUrl) && photo.DoesLargeExist)
                    {
                        BiggestVersionUrl = photo.LargeUrl;
                    }
                    else if (!string.IsNullOrEmpty(photo.MediumUrl) && photo.DoesMediumExist)
                    {
                        BiggestVersionUrl = photo.MediumUrl;
                    }
                    else if (!string.IsNullOrEmpty(photo.SmallUrl))
                    {
                        BiggestVersionUrl = photo.SmallUrl;
                    }


The result is: DoesLargeExist and DoesMediumExist always return false, so my image urls are always assigned to the smallest verion url.
Do I have any missing? Please help!!!!
Coordinator
Jan 22, 2013 at 10:01 AM
Edited Jan 22, 2013 at 10:02 AM

Your best bet it to ask for all the urls using the extras parameter:

var options = new PhotoSearchOptions {
    Extras = PhotoSearchExtras.AllUrls,
    UserId = userId
};
var photos = flickr.PhotoSearch(options)

After that the DoesLargeExist and DoesMediumExist should work as expected.

Sam

Jan 22, 2013 at 10:42 AM
Edited Jan 22, 2013 at 11:00 AM

Hi Sam,

It works perfectly after I change the PhotoSearchExtras from OriginalUrl to AllUrls as your suggestion. :).

Thank you so  much for your support.

Rubik