/// <summary> /// Creates Image Field /// </summary> /// <param name="fieldAttributes"> /// Field Configuration Attributes /// </param> /// <returns> /// Image <see cref="UPMEditField"/>. /// </returns> private UPMImageEditField CreateImageField(FieldAttributes fieldAttributes) { var imageEditField = new UPMImageEditField(FieldIdentifier); var attribute = fieldAttributes.AttributForId((int)FieldAttr.Image); var previewWidth = attribute.ValueOptionsForKey(KeyPreviewWidth); var previewHeight = attribute.ValueOptionsForKey(KeyPreviewHeight); imageEditField.ImageDocumentMaxSize = new Size(176, 176); if (previewWidth != null && previewHeight != null) { var width = JObjectExtensions.ToInt(previewWidth); var height = JObjectExtensions.ToInt(previewHeight); imageEditField.ImageDocumentMaxSize = new Size(width, height); } var explicitFileName = attribute.ValueOptionsForKey(KeyFileNamePattern) as string; if (explicitFileName != null) { imageEditField.ExplicitFileName = explicitFileName; } var documentKey = Value; if (!string.IsNullOrWhiteSpace(documentKey)) { var documentManager = new DocumentManager(); var documentData = documentManager.DocumentForKey(documentKey); imageEditField.ImageDocument = new UPMDocument( FieldIdentifier, null, null, null, null, documentData?.Url ?? ServerSession.CurrentSession.DocumentRequestUrlForDocumentKey(documentKey), documentData?.Title, null, null, documentData?.UrlForD1RecordId()); } return(imageEditField); }