Copied to clipboard

Flag this post as spam?

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


  • Jonathan Roberts 409 posts 1063 karma points
    Apr 27, 2017 @ 09:24
    Jonathan Roberts
    0

    Archetype using Image Cropper

    Hi,

    How do I get the Image Cropper working with Archetype? I am using this to get the URL the old way but need a way to get the Image Cropper:

    @Umbraco.Media(fieldset.GetValue("blockImage"))

    Im using Umbraco 7.4.3.

    Jon

  • Neil Hodges 338 posts 987 karma points
    May 04, 2017 @ 16:01
    Neil Hodges
    100

    Hi Jon

    This thread my shed some light on it - https://github.com/kgiszewski/Archetype/issues/255

  • Allan 42 posts 192 karma points
    Nov 28, 2018 @ 16:37
    Allan
    0

    I found a work around...

    The crop data is stored as json inside the Archetype so you can extract it then re-create the url using the data.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using Archetype.Models;
    @using Archetype.Extensions;
    @using Newtonsoft.Json.Linq;
    @{
        foreach (var itm in CurrentPage.GetPropertyValue<ArchetypeModel>("moreImages"))
        {
            string[] c = { "0", "0", "0", "0" };
            string src;
    
            JObject o = JObject.Parse(itm.GetValue("additionalImage"));
            // SOURCE
            src = o["src"].ToString() + "?crop=";
            // CROPS - I needed the 5th crop but you can adapt...
            if (o["crops"][5]["coordinates"] != null)
            {
                c[0] = o["crops"][5]["coordinates"]["x1"].ToString();
                c[1] = o["crops"][5]["coordinates"]["y1"].ToString();
                c[2] = o["crops"][5]["coordinates"]["x2"].ToString();
                c[3] = o["crops"][5]["coordinates"]["y2"].ToString();
            }
            for (int a = 0; a < c.Length; a++)
            {
                src = src + c[a] + ",";
            }
            src = src.TrimEnd(",") + "&cropmode=percentage&width=600&height=600";
            <img class="content-page-image" src="@src" alt="@itm.GetValue("imageTitle")"/>          
        }
    }
    

    Its not the cleanest or tidiest way of doing things, but it worked for me!

Please Sign in or register to post replies

Write your reply to:

Draft