public override void UpdateEditor(global::N2.ContentItem item, Control editor) { LinkItemCollection coll = LinkItemCollection.FindByPageAndPropertyName(item, Name); ImageGalleryControl ctrl = ((ImageGalleryControl)editor); IDynamicImageUtility dynamicImageUtility = GetDynamicImageUtility(); //Need to convert the ImageItem objects to ImageGalleryItemEditDTO objects List <ImageGalleryItemEditDTO> lstImageGalleryItemEditDTO = coll.Cast <ImageItem>().Select(x => { var dto = ImageGalleryAutoMapperMappings.Instance.Map <ImageGalleryItemEditDTO>(x); dto.ThumbnailUrl = VirtualPathUtility.ToAppRelative(dynamicImageUtility.GenerateVirtualPath(dto.Url, new DynamicImageOptions(dto.Url, 150, 150, DynamicResizeMode.UniformFill, DynamicImageFormat.Jpeg))); return(dto); }).ToList(); ctrl.Initialize(JsonConvert.SerializeObject(lstImageGalleryItemEditDTO), coll.Count); }
public override bool UpdateItem(global::N2.ContentItem item, Control editor) { string value = ((ImageGalleryControl)editor).Value; string jsonSave = null; if (!string.IsNullOrEmpty(value)) { //We need to convert the JSON items from ImageGalleryItemEditDTO objects to ImageItem objects List <ImageGalleryItemEditDTO> lstImageGalleryItemEditDTO = JsonConvert.DeserializeObject <List <ImageGalleryItemEditDTO> >(value); //Now convert the items List <ImageItem> lstImageItem = ImageGalleryAutoMapperMappings.Instance.Map <List <ImageItem> >(lstImageGalleryItemEditDTO); //Now convert to JSON for storage in the N2 database jsonSave = JsonConvert.SerializeObject(lstImageItem); } item.SetDetail(Name, jsonSave, typeof(string)); return(true); }
public override void UpdateEditor(global::N2.ContentItem item, Control editor) { ControlUtility.FormatPropertyControl(Name, item, editor); base.UpdateEditor(item, editor); }