public FieldSuiteImage(FieldSuiteImageArgs args) : base(args) { if (args.InnerItem.IsNull() || args.Node == null || args.Node.Attributes["imageField"] == null) { return; } string titleField = null; string imageField = args.Node.Attributes["imageField"].Value; if (args.Node.Attributes["titleField"] != null) { titleField = args.Node.Attributes["titleField"].Value; } //get title, fall back to display name Title = args.InnerItem.DisplayName; if (!string.IsNullOrEmpty(titleField)) { Title = args.InnerItem[titleField]; } //image field source ImageField imageFieldObject = args.InnerItem.Fields[imageField]; if (imageFieldObject == null || imageFieldObject.MediaItem == null) { return; } MediaUrlOptions options = new MediaUrlOptions(); options.AbsolutePath = true; options.UseItemPath = true; ImageUrl = MediaManager.GetMediaUrl(imageFieldObject.MediaItem, options); if (string.IsNullOrEmpty(ImageUrl)) { return; } }
public MediaImage(FieldSuiteImageArgs args) : base(args) { if (args == null || args.InnerItem.IsNull()) { return; } if (!args.InnerItem.Paths.IsMediaItem) { return; } MediaItem mediaItem = args.InnerItem; MediaUrlOptions options = new MediaUrlOptions(); options.AbsolutePath = true; options.UseItemPath = true; Title = mediaItem.DisplayName; ImageUrl = MediaManager.GetMediaUrl(mediaItem, options); }
/// <summary> /// Return Velir Image from reflection /// </summary> /// <param name="node"></param> /// <param name="currentItem"></param> /// <param name="titleField"></param> /// <param name="imagefield"></param> /// <returns></returns> private static IFieldSuiteImage GetItem_FromReflection(XmlNode node, Item currentItem) { //verify we can break up the type string into a namespace and assembly name string[] split = node.Attributes["type"].Value.Split(','); if (split.Length == 0) { return(null); } string Namespace = split[0]; string AssemblyName = split[1]; // load the assemly Assembly assembly = GetAssembly(AssemblyName); // Walk through each type in the assembly looking for our class Type type = assembly.GetType(Namespace); if (type == null || !type.IsClass) { return(null); } FieldSuiteImageArgs args = new FieldSuiteImageArgs(); args.InnerItem = currentItem; args.Node = node; object[] parameters = new object[1]; parameters[0] = args; //cast to validator class IFieldSuiteImage fieldSuiteImage = (IFieldSuiteImage)Activator.CreateInstance(type, parameters); //validate return(fieldSuiteImage); }
protected AFieldSuiteImage(FieldSuiteImageArgs args) { }