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.
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");
Hi,
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?
Caller:
String imagedescription = GetMetaDataFromImageURL(CurrentPage["MainIntroPicture"].ToString(), "Description");
Funcition:
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;
}