Thanks Dave. My requirement is to modify these cocordinates programatically from the front-end, so I'm thinking I'm going to need to write something custom that can modify that JSON. Where is the JSON stored?
Thanks Dave. I'm just struggling to find how/where to modify this data programatically. I can't seem to find it saved in the database (could be there, but can't see it) and I can't find any API methods to be able to set these values.
Edit; I'm happy to write my own logic to be able to do this, but my problem is that I don't know where the focal point data is actually saved to know what I need to update.
It's a long story ;) Basically I need to build a very light pseudo-admin-system but with very strict browser support requirements (IE8+). So I need to replicate an image upload facility on a front-end dashboard (which I've pretty much done, using the media service API) but also need to allow editors to manage the position of the focal point. Unfortunately due to the browser requirements I can't use Angular and pull in the Umbraco directives - it's probably going to be jQuery. I do need some means of saving new values for the focal point for a media item though, that's my immediate problem.
Thanks Dave. I'll have a read through that stuff as it seems it'll need a lot of digestion. In my mind I'm still struggling with the core question of where the crop data for a media item is coming from. When it's read, it must be being read from the media cache, that's fine and I totally get how to output that data, but when it's written, where is it actually saved to? I think I'm probably missing something obvious, but if I could just find out where, fundamentally, the focus point data is being saved, then I can probably understand better how to interface with that data and write to it.
Did you ever figure this out Dan or is it still a head scratcher? I am trying to save images from an old Umbraco project to a new one, and I have the focal point data to use, but don't know how to set that value. Focal point doesn't seem to be a property of the Image DataType
Set focal point programatically
Hi,
Is there a way to save focal point coordinates to a media item programatically? Where is this data actually stored?
Thanks
It is stored in the json generated by the image cropper datatype. THere is a focalPoint property with a left and right property.
...
focalPoint : {
left : 0.5,
top : 0.5
}
The above is for a focal point in the middle of your image.
Dave
Thanks Dave. My requirement is to modify these cocordinates programatically from the front-end, so I'm thinking I'm going to need to write something custom that can modify that JSON. Where is the JSON stored?
If you use the cropper in the media section, the umbracoFile property of the Image will have this json.
Dave
Thanks Dave. I'm just struggling to find how/where to modify this data programatically. I can't seem to find it saved in the database (could be there, but can't see it) and I can't find any API methods to be able to set these values.
Edit; I'm happy to write my own logic to be able to do this, but my problem is that I don't know where the focal point data is actually saved to know what I need to update.
Can I ask why you want do this ? Maybe there is another way around this than changing the contents of the property.
Dave
It's a long story ;) Basically I need to build a very light pseudo-admin-system but with very strict browser support requirements (IE8+). So I need to replicate an image upload facility on a front-end dashboard (which I've pretty much done, using the media service API) but also need to allow editors to manage the position of the focal point. Unfortunately due to the browser requirements I can't use Angular and pull in the Umbraco directives - it's probably going to be jQuery. I do need some means of saving new values for the focal point for a media item though, that's my immediate problem.
I think you can use the approach described in this article : http://24days.in/umbraco/2014/working-with-complex-archetype-datatypes/
The similar approach can be used for the image cropper. The only thing you need is PropertyValueConvertor for the image cropper.
That can be found in the Hybrid Framework : https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises/blob/master/Umbraco.Extensions/PropertyConverters/ImageCropperConverter.cs
Dave
Thanks Dave. I'll have a read through that stuff as it seems it'll need a lot of digestion. In my mind I'm still struggling with the core question of where the crop data for a media item is coming from. When it's read, it must be being read from the media cache, that's fine and I totally get how to output that data, but when it's written, where is it actually saved to? I think I'm probably missing something obvious, but if I could just find out where, fundamentally, the focus point data is being saved, then I can probably understand better how to interface with that data and write to it.
Did you ever figure this out Dan or is it still a head scratcher? I am trying to save images from an old Umbraco project to a new one, and I have the focal point data to use, but don't know how to set that value. Focal point doesn't seem to be a property of the Image DataType
I didn't solve it Mike - it was for a personal project which I dropped ages ago.
is working on a reply...