/// <summary> /// </summary> /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param> private void DataEditorControl_OnSave(EventArgs e) { var prevalueEditor = (ImageResizerPrevalueEditor)PrevalueEditor; var imageUrl = ImageResizerHelper.ResizeImage(ImageResizerHelper.GetOriginalUrl(ImageResizerHelper.CurrentNodeId, prevalueEditor), prevalueEditor.MaxHeight, prevalueEditor.MaxWidth); _imageResizerDataEditor.ImageUrl = imageUrl; base.Data.Value = _imageResizerDataEditor.ImageUrl; }
/// <summary> /// Handles the PreRender event of the _colorPickerDataEditor control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void ImageResizerDataEditorPreRender(object sender, EventArgs e) { var prevalueEditor = (ImageResizerPrevalueEditor)PrevalueEditor; _imageResizerDataEditor.PropertyAlias = prevalueEditor.PropertyAlias; _imageResizerDataEditor.ImageUrl = base.Data.Value.ToString(); var propertyOk = ImageResizerHelper.GetOriginalUrl(ImageResizerHelper.CurrentNodeId, prevalueEditor) != string.Empty; _imageResizerDataEditor.Toggle(propertyOk); if (propertyOk) { _imageResizerDataEditor.LabelText = string.Format("<p>{0}</p>", ImageResizerHelper.GetSizeString(_imageResizerDataEditor.ImageUrl)); } }
/// <summary> /// Processes the properties. /// Will resize images when ImageResizer property is found /// </summary> /// <param name="node">The node.</param> private static void ProcessProperties(Content node) { var nodeId = node.Id; var properties = node.GenericProperties; foreach (var property in properties) { // Check if this is an ImageResizer property if (property.PropertyType.DataTypeDefinition.DataType.Id != ImageResizerHelper.DataTypeId) { continue; } // Resize the image var prevalueEditor = (ImageResizerPrevalueEditor)property.PropertyType.DataTypeDefinition.DataType.PrevalueEditor; ImageResizerHelper.ResizeImage(ImageResizerHelper.GetOriginalUrl(nodeId, prevalueEditor), prevalueEditor.MaxHeight, prevalueEditor.MaxWidth); } }