Thanks for this - I managed to sort it in the end just didn't get round to posting my solution yet.
Thanks for your help though.
var services = ApplicationContext.Current.Services;
var dt = services.DataTypeService;
var imgCrop = dt.GetDataTypeDefinitionByName("Image Cropper");
var preValues = dt.GetPreValuesCollectionByDataTypeId(imgCrop.Id).PreValuesAsDictionary;
var dict = new Dictionary<string, PreValue>
{
{ "Crops", new PreValue("[{\"alias\": \"6 by 4\",\"width\": 720,\"height\": 480}]") },
};
dt.SaveDataTypeAndPreValues(imgCrop, dict);
Create new Crop Sizes Dynamically in C#
Hello,
I need to create 4 crop profiles for the Image Cropper datatype dynamically in C#. How would one do this? Can this be done using the DTS?
var dt = ApplicationContext.Current.Services.DataTypeService;
Thanks
Paul
Hi
the crop information is stored as a bit of JSON in the datatype. under the 'crops' property.
e.g.
yes you can use the datatype service to get to this. as an example (but try to avoid ApplicationContext.Current if you can)
That should be a start, it might need the odd tweak as i haven't tested that code just typed it.
Kevin
Hi Kevin,
Thanks for this - I managed to sort it in the end just didn't get round to posting my solution yet.
Thanks for your help though.
is working on a reply...