Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan 1288 posts 3921 karma points c-trib
    Dec 16, 2014 @ 21:54
    Dan
    0

    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

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Dec 17, 2014 @ 08:47
    Dave Woestenborghs
    0

    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 

  • Dan 1288 posts 3921 karma points c-trib
    Dec 17, 2014 @ 09:23
    Dan
    0

    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?

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Dec 17, 2014 @ 09:55
    Dave Woestenborghs
    0

    If you use the cropper in the media section, the umbracoFile property of the Image will have this json.

    Dave

  • Dan 1288 posts 3921 karma points c-trib
    Dec 17, 2014 @ 10:10
    Dan
    0

    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.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Dec 17, 2014 @ 12:07
    Dave Woestenborghs
    0

    Can I ask why you want do this ? Maybe there is another way around this than changing the contents of the property.

    Dave

  • Dan 1288 posts 3921 karma points c-trib
    Dec 17, 2014 @ 12:24
    Dan
    0

    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.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Dec 17, 2014 @ 12:30
    Dave Woestenborghs
    0

    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

  • Dan 1288 posts 3921 karma points c-trib
    Dec 17, 2014 @ 12:37
    Dan
    0

    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.

  • Mike Ryan 10 posts 91 karma points
    Mar 22, 2017 @ 15:54
    Mike Ryan
    0

    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

  • Dan 1288 posts 3921 karma points c-trib
    Mar 22, 2017 @ 16:18
    Dan
    0

    I didn't solve it Mike - it was for a personal project which I dropped ages ago.

Please Sign in or register to post replies

Write your reply to:

Draft