How to achieve description of image stored in the file manager of Episerver

Jon Haakon Ariansen
Member since: 2005


I have a problem achieving the meta data from files stored in the file manager in Episerver.

There is a function in our solution that is supposed to fix this, but often it doesn't work.

I use the function below to get description information from the files, but very often it returns nothing.

Anyone have a better/safer method to get the description information stored on files in Episerver - File manager?



String imagedescription = GetMetaDataFromImageURL(CurrentPage["MainIntroPicture"].ToString(), "Description");



protected static string GetMetaDataFromImageURL(string imageurl, string metainstance)

string s = string.Empty;
if (imageurl!=null)
UnifiedFile uf = HostingEnvironment.VirtualPathProvider.GetFile(imageurl) as UnifiedFile;
if (uf != null)
if (uf.Summary.Dictionary[metainstance] != null)
s = uf.Summary.Dictionary[metainstance].ToString();
return s;

#65900 Feb 13, 2013 17:08
  • Arild Henrichsen
    Member since: 2008

    Just tried your code, it works.

    I'm guessing your MainIntroPicture property is of type "URL to image"? (which will render a relative path to the file, like "/Global/Images/mypicture.jpg")

    However, you shouldn't do CurrentPage["MainIntroPicture"].ToString(), since it will throw a NULL reference exception if the property has no value set. Do GetMetaDataFromImageURL(CurrentPage["MainIntroPicture"] as string, "Description") instead, or CurrentPage.MainIntroPicture if you're using PTB.


    #65911 Feb 13, 2013 22:09
  • Jon Haakon Ariansen
    Member since: 2005

    Good tip Arild, I will change that.

    I found the error. They say you can't see the forrest because of all the trees.

    Kind of the same here. You can't see the function-error because of all the code.

    I was missing Server.UrlDecode on CurrentPage["MainIntroPicture"].

    Correct code is:

    String imagedescription = GetMetaDataFromImageURL(Server.UrlDecode(CurrentPage["MainIntroPicture"] as String), "Description");


    #65936 Feb 15, 2013 10:21