diff --git a/src/Umbraco.Web.UI.Client/src/views/directives/imaging/umb-image-thumbnail.html b/src/Umbraco.Web.UI.Client/src/views/directives/imaging/umb-image-thumbnail.html
index 765787b48e..32626ecb3f 100644
--- a/src/Umbraco.Web.UI.Client/src/views/directives/imaging/umb-image-thumbnail.html
+++ b/src/Umbraco.Web.UI.Client/src/views/directives/imaging/umb-image-thumbnail.html
@@ -1,4 +1,4 @@
-

+
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/cropsizes.controller.js b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/cropsizes.controller.js
new file mode 100644
index 0000000000..78b333175d
--- /dev/null
+++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/cropsizes.controller.js
@@ -0,0 +1,34 @@
+angular.module("umbraco").controller("Umbraco.PrevalueEditors.CropSizesController",
+ function ($scope, $timeout) {
+
+ $scope.newItem = {};
+
+ if(!$scope.model.value){
+ $scope.model.value = [];
+ }
+
+ $scope.remove = function(item, evt) {
+ evt.preventDefault();
+ $scope.model.value = _.reject($scope.model.value, function (x) {
+ return x.alias === item.alias;
+ });
+ };
+
+ $scope.add = function (evt) {
+
+ evt.preventDefault();
+
+ if ($scope.newItem) {
+ var exists = _.find($scope.model.value, function(item){return $scope.newItem.alias === item.alias;});
+ if (!exists){
+ $scope.model.value.push($scope.newItem);
+ $scope.newItem = {};
+ $scope.hasError = false;
+ return;
+ }
+ }
+
+ //there was an error, do the highlight (will be set back by the directive)
+ $scope.hasError = true;
+ };
+ });
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/cropsizes.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/cropsizes.html
new file mode 100644
index 0000000000..b1a62dda20
--- /dev/null
+++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/cropsizes.html
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs
index 719b6529e6..940d7b8251 100644
--- a/src/Umbraco.Web/Editors/BackOfficeController.cs
+++ b/src/Umbraco.Web/Editors/BackOfficeController.cs
@@ -182,11 +182,6 @@ namespace Umbraco.Web.Editors
"rteApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl
(
controller => controller.GetConfiguration())
},
- {
- "imageCropperApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl(
- controller => controller.GetConfiguration(string.Empty))
- },
-
{
"stylesheetApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl(
controller => controller.GetAll())
@@ -261,7 +256,7 @@ namespace Umbraco.Web.Editors
: string.Format("{0}-{1}", UmbracoVersion.Current.ToString(3), UmbracoVersion.CurrentComment);
app.Add("version", version);
-
+ app.Add("cdf", ClientDependency.Core.Config.ClientDependencySettings.Instance.Version);
return app;
}
diff --git a/src/Umbraco.Web/ImageCropperBaseExtensions.cs b/src/Umbraco.Web/ImageCropperBaseExtensions.cs
index 53a62853a2..e74263afc6 100644
--- a/src/Umbraco.Web/ImageCropperBaseExtensions.cs
+++ b/src/Umbraco.Web/ImageCropperBaseExtensions.cs
@@ -34,7 +34,6 @@ namespace Umbraco.Web
return ic;
}
-
internal static ImageCropDataSet SerializeToCropDataSet(this string json)
{
var imageCrops = new ImageCropDataSet();
@@ -44,9 +43,9 @@ namespace Umbraco.Web
{
imageCrops = JsonConvert.DeserializeObject(json);
}
- catch
+ catch(Exception ex)
{
-
+ var e = ex;
}
}
@@ -105,8 +104,8 @@ namespace Umbraco.Web
if (allTheCrops != null && allTheCrops.Crops.Any())
{
var crop = cropAlias != null
- ? allTheCrops.Crops[cropAlias]
- : allTheCrops.Crops.First().Value;
+ ? allTheCrops.Crops.First(x => x.Alias ==cropAlias)
+ : allTheCrops.Crops.First();
if (crop != null)
{
return true;
@@ -131,8 +130,8 @@ namespace Umbraco.Web
if (allTheCrops != null && allTheCrops.Crops.Any())
{
var crop = cropAlias != null
- ? allTheCrops.Crops[cropAlias]
- : allTheCrops.Crops.First().Value;
+ ? allTheCrops.Crops.First(x => x.Alias ==cropAlias)
+ : allTheCrops.Crops.First();
if (crop != null)
{
return true;
diff --git a/src/Umbraco.Web/ImageCropperTemplateExtensions.cs b/src/Umbraco.Web/ImageCropperTemplateExtensions.cs
index 62fb504f7a..cc48a47744 100644
--- a/src/Umbraco.Web/ImageCropperTemplateExtensions.cs
+++ b/src/Umbraco.Web/ImageCropperTemplateExtensions.cs
@@ -10,11 +10,7 @@ namespace Umbraco.Web
{
public static class ImageCropperTemplateExtensions
{
- public static bool HasCrop(this IPublishedContent publishedContent, string propertyAlias, string cropAlias)
- {
- return ImageCropperPropertyEditorHelper.GetCrop(publishedContent.ContentType.Alias, cropAlias) != null;
- }
-
+
//this only takes the crop json into account
public static string Crop(this IPublishedContent mediaItem, string propertyAlias, string cropAlias)
{
@@ -26,7 +22,7 @@ namespace Umbraco.Web
if (property.IsJson())
{
var cropDataSet = property.SerializeToCropDataSet();
- var currentCrop = cropDataSet.Crops[cropAlias];
+ var currentCrop = cropDataSet.Crops.First(x => x.Alias ==cropAlias);
return cropDataSet.Src + currentCrop.ToUrl();
}
else
@@ -38,10 +34,7 @@ namespace Umbraco.Web
}
-
-
-
- public static string Crop(
+ public static string Crop(
this IPublishedContent mediaItem,
int? width = null,
int? height = null,
@@ -72,7 +65,7 @@ namespace Umbraco.Web
Mode? mode = null,
Anchor? anchor = null,
string imageCropperValue = null,
- string imageCropperCropId = null,
+ string cropAlias = null,
string furtherOptions = null,
bool slimmage = false)
{
@@ -86,9 +79,9 @@ namespace Umbraco.Web
var allTheCrops = imageCropperValue.SerializeToCropDataSet();
if (allTheCrops != null && allTheCrops.Crops.Any())
{
- var crop = imageCropperCropId != null
- ? allTheCrops.Crops[imageCropperCropId]
- : allTheCrops.Crops.First().Value;
+ var crop = cropAlias != null
+ ? allTheCrops.Crops.First(x => x.Alias ==cropAlias)
+ : allTheCrops.Crops.First();
if (crop != null)
{
imageResizerUrl.Append(crop.ToUrl());
diff --git a/src/Umbraco.Web/Models/ContentEditing/ContentPropertyBasic.cs b/src/Umbraco.Web/Models/ContentEditing/ContentPropertyBasic.cs
index cdebd65d33..942766aa40 100644
--- a/src/Umbraco.Web/Models/ContentEditing/ContentPropertyBasic.cs
+++ b/src/Umbraco.Web/Models/ContentEditing/ContentPropertyBasic.cs
@@ -21,6 +21,10 @@ namespace Umbraco.Web.Models.ContentEditing
[Required(AllowEmptyStrings = false)]
public string Alias { get; set; }
+ [DataMember(Name = "editor", IsRequired = false)]
+ public string Editor { get; set; }
+
+
///
/// Used internally during model mapping
///
diff --git a/src/Umbraco.Web/Models/ImageCropData.cs b/src/Umbraco.Web/Models/ImageCropData.cs
index ad0448e8a7..fdee53fbac 100644
--- a/src/Umbraco.Web/Models/ImageCropData.cs
+++ b/src/Umbraco.Web/Models/ImageCropData.cs
@@ -13,17 +13,11 @@ namespace Umbraco.Web.Models
[DataMember(Name="src")]
public string Src { get; set;}
- [DataMember(Name = "imagePropertyAlias")]
- public string ImagePropertyAlias { get; set; }
-
- [DataMember(Name = "focalPointPropertyAlias")]
- public string FocalPointPropertyAlias { get; set; }
-
[DataMember(Name = "focalPoint")]
public ImageCropFocalPoint FocalPoint { get; set; }
[DataMember(Name = "crops")]
- public IDictionary Crops { get; set; }
+ public IEnumerable Crops { get; set; }
}
[DataContract(Name = "imageCropFocalPoint")]
@@ -59,8 +53,8 @@ namespace Umbraco.Web.Models
[DataMember(Name = "alias")]
public string Alias { get; set; }
- [DataMember(Name = "name")]
- public string Name { get; set; }
+ //[DataMember(Name = "name")]
+ //public string Name { get; set; }
[DataMember(Name = "width")]
public int Width { get; set; }
diff --git a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs
index f95f9f6627..f61d9adf77 100644
--- a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs
+++ b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs
@@ -44,7 +44,8 @@ namespace Umbraco.Web.Models.Mapping
Id = property.Id,
Value = editor.ValueEditor.ConvertDbToEditor(property, property.PropertyType, DataTypeService.Value),
Alias = property.Alias,
- PropertyEditor = editor
+ PropertyEditor = editor,
+ Editor = editor.Alias
};
return result;
diff --git a/src/Umbraco.Web/PropertyEditors/ImageCropperPrevalueController.cs b/src/Umbraco.Web/PropertyEditors/ImageCropperPrevalueController.cs
deleted file mode 100644
index 1a1f7ae6ec..0000000000
--- a/src/Umbraco.Web/PropertyEditors/ImageCropperPrevalueController.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Umbraco.Core.Configuration;
-using Umbraco.Web.Editors;
-using Umbraco.Web.Mvc;
-
-namespace Umbraco.Web.PropertyEditors
-{
-
- public class ImageCropperPreValueController : UmbracoAuthorizedJsonController
- {
- //Returns the collection of allowed crops on a given media alias type
- public Models.ImageCropDataSet GetConfiguration(string mediaTypeAlias)
- {
- return ImageCropperPropertyEditorHelper.GetConfigurationForType(mediaTypeAlias);
- }
-
- //Returns a specific crop on a media type
- public Models.ImageCropData GetCrop(string mediaTypeAlias, string cropAlias)
- {
- return ImageCropperPropertyEditorHelper.GetCrop(mediaTypeAlias, cropAlias);
- }
- }
-}
diff --git a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs
index b58b49872c..268a0558ba 100644
--- a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs
+++ b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs
@@ -21,5 +21,34 @@ namespace Umbraco.Web.PropertyEditors
var baseEditor = base.CreateValueEditor();
return new ImageCropperPropertyValueEditor(baseEditor);
}
+
+ protected override PreValueEditor CreatePreValueEditor()
+ {
+ return new ImageCropperPreValueEditor();
+ }
+
+
+ public ImageCropperPropertyEditor()
+ {
+ _internalPreValues = new Dictionary
+ {
+ {"crops", "[]"},
+ {"focalPoint", "{left: 0.5, top: 0.5}"},
+ {"src", ""}
+ };
+ }
+
+ private IDictionary _internalPreValues;
+ public override IDictionary DefaultPreValues
+ {
+ get { return _internalPreValues; }
+ set { _internalPreValues = value; }
+ }
+
+ internal class ImageCropperPreValueEditor : PreValueEditor
+ {
+ [PreValueField("crops", "Crop sizes", "cropsizes")]
+ public string Crops { get; set; }
+ }
}
}
diff --git a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditorHelper.cs b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditorHelper.cs
index ff9432a5af..f82e08da71 100644
--- a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditorHelper.cs
+++ b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditorHelper.cs
@@ -9,44 +9,29 @@ namespace Umbraco.Web.PropertyEditors
{
internal class ImageCropperPropertyEditorHelper
{
- //Returns the collection of allowed crops on a given media alias type
- internal static Models.ImageCropDataSet GetConfigurationForType(string mediaTypeAlias)
- {
- var defaultModel = new Models.ImageCropDataSet();
- defaultModel.FocalPoint = new Models.ImageCropFocalPoint() { Left = 0.5M, Top = 0.5M };
-
- var configuredCrops = UmbracoConfig.For.UmbracoSettings().Content.ImageCrops.Crops.FirstOrDefault(x => x.MediaTypeAlias == mediaTypeAlias);
- if (configuredCrops == null || !configuredCrops.CropSizes.Any())
- return defaultModel;
-
- var crops = new Dictionary();
- foreach (var cropSize in configuredCrops.CropSizes)
- crops.Add(cropSize.Alias, new Models.ImageCropData() { Alias = cropSize.Alias, Height = cropSize.Height, Width = cropSize.Width });
-
-
- defaultModel.Crops = crops;
- return defaultModel;
- }
-
+
internal static Umbraco.Web.Models.ImageCropData GetCrop(string mediaTypeAlias, string cropAlias){
- var _crops = GetConfigurationForType(mediaTypeAlias);
+ return null;
+
+ /*var _crops = GetConfigurationForType(mediaTypeAlias);
if (_crops == null || _crops.Crops == null)
return null;
- return _crops.Crops[cropAlias];
+ return _crops.Crops[cropAlias];*/
}
//this queries all crops configured
internal static Umbraco.Web.Models.ImageCropData GetCrop(string cropAlias)
{
+ /*
foreach (var typeCrops in UmbracoConfig.For.UmbracoSettings().Content.ImageCrops.Crops)
{
var cropSize = typeCrops.CropSizes.FirstOrDefault(x => x.Alias == cropAlias);
if(cropSize != null)
return new Models.ImageCropData() { Alias = cropSize.Alias, Height = cropSize.Height, Width = cropSize.Width };
- }
+ }*/
return null;
}
diff --git a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs
index 35f24aa23c..6568138518 100644
--- a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs
+++ b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs
@@ -23,6 +23,7 @@ namespace Umbraco.Web.PropertyEditors
}
+
///
/// Overrides the deserialize value so that we can save the file accordingly
///
@@ -62,7 +63,7 @@ namespace Umbraco.Web.PropertyEditors
//compare old and new src path
//if not alike, that means we have a new file, or delete the current one...
- if (oldFile != newFile)
+ if (string.IsNullOrEmpty(newFile) || editorValue.AdditionalData.ContainsKey("files"))
{
var fs = FileSystemProviderManager.Current.GetFileSystemProvider();
@@ -118,4 +119,6 @@ namespace Umbraco.Web.PropertyEditors
return editorValue.Value.ToString();
}
}
+
+
}