Reputation: 187
We have upgraded a sitecore application from 6.2 to 7.1 recently.
We are facing a critical issue when we upload an image to an image field and when we see the raw value for an image field it only has the mediaid
and is missing mediapath
and src
fields.
All the recently uploaded images are having this problem. We have 6.2 migrated code depending on this raw value and hence application is not working for images. We are unable to see them on the site when we publish the item. Other images which have the mediapath
, src
fields along with mediaid
are appearing on the site.
Please help us in resolving this.
Sitecore Version : 7.1 rev 130926
Upvotes: 1
Views: 765
Reputation: 5860
Well the short story is; you should not be relying on raw values in fields. Not media fields, not in any fields. Sitecore does not guarantee the raw storage format of fields.
A correct way to get a media URL is as follows:
ImageField imageField = myItem.Fields["my image field"];
if (imageField.MediaItem != null)
{
string url = MediaManager.GetMediaUrl(imageField.MediaItem);
}
Upvotes: 1