I am on Sitecore 7.2
I am experiencing issues trying to retrieve media URL.
I have a template (
PageBanner) with just one field called
BannerImage. Field type is
Another template named
Homepage inherits this template
A content item
Home uses template
Homepage. I can see the
BannerImage field as a part of the
Home content item. An image has been assigned to this field as well.
Now, the back-end bit where the issue is encountered.
homeItem.Field["BannerImage"] returns image item.
homeItem["BannerImage"] returns empty string.
If I try to cast it to ImageField -
(ImageField)homeItem.Field["BannerImage"], the resultant ImageField item doesn't have
MediaItem or any other field set.
I can do :
var imageFieldItem = Sitecore.Context.Database.GetItem(homeItem.Fields["BannerImage"].ID);
var mediaUrl = MediaManager.GetMediaUrl(imageFieldItem);
But that gives me a dynamic media url in the form of -
I am looking to get the media URL by path.
Any idea what am I missing here?