Don't hardcode the umbracoFile constant

This commit is contained in:
Sebastiaan Janssen
2016-01-12 20:05:22 +01:00
parent 43227d4510
commit 8e024fccff

View File

@@ -137,21 +137,21 @@ namespace Umbraco.Web.Models.Mapping
}
};
if (media.Properties.FirstOrDefault(x => x.Alias == Constants.Conventions.Media.File) != null)
var helper = new UmbracoHelper(UmbracoContext.Current);
var mediaItem = helper.TypedMedia(media.Id);
if (mediaItem != null)
{
var helper = new UmbracoHelper(UmbracoContext.Current);
var mediaItem = helper.TypedMedia(media.Id);
if (mediaItem != null)
var crops = new List<string>();
var autoFillProperties = UmbracoConfig.For.UmbracoSettings().Content.ImageAutoFillProperties.ToArray();
if (autoFillProperties.Any())
{
var crops = new List<string>();
var autoFillProperties = UmbracoConfig.For.UmbracoSettings().Content.ImageAutoFillProperties;
foreach (var field in autoFillProperties)
{
var crop = mediaItem.GetCropUrl(field.Alias, string.Empty);
if (string.IsNullOrWhiteSpace(crop) == false)
crops.Add(crop.Split('?')[0]);
}
if (crops.Any())
{
var link = new ContentPropertyDisplay