Copied to clipboard

Flag this post as spam?

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


  • Johan Plesner Hamann 105 posts 199 karma points
    Apr 06, 2014 @ 23:52
    Johan Plesner Hamann
    0

    Image cropper and Media Picker

    Hey

    I try to grab images from a folder using Media Picker and Image cropper, I have saved images again after I changed the upload to Image cropper. it's all from a Macro, and the Macro is not at the same level as the Document Type that is referring to the media folder. 

    structure:

    Document Type with Media Picker property (images) must refer to a media folder, and not a single image.

    Media Type with Image cropper property (umbracoFile)

    @inherits umbraco.MacroEngines.DynamicNodeContext
    
    @foreach (var item in Model.Children)
    {
        <h1>@item.images</h1>
    
        foreach (var crop in Library.MediaById(item.images).Children)
        {
            <p>1: @crop</p>
            <p>2: @crop.Name</p>
            <p>3: @crop.Url </p>
            <p>4: @crop.umbracoFile </p>
            <p>5: @crop.src </p>
            <p>6: @crop.GetCropUrl("Url", "thumb")</p>
            <p>7: @crop.GetCropUrl("umbracoFile", "thumb")</p>
        }
    

    1:  umbraco.MacroEngines.DynamicNode

    2: WP_000110.jpg

    3: { "focalPoint": { "left": 0.5, "top": 0.5 }, "src": "/media/1005/wp_000110.jpg", "crops": [ { "alias": "thumb", "width": 220, "height": 220 } ] }

    4: { "focalPoint": { "left": 0.5, "top": 0.5 }, "src": "/media/1005/wp_000110.jpg", "crops": [ { "alias": "thumb", "width": 220, "height": 220 } ] }

    5: 

    6:

    7:

     

    But I can not get it to work. Hope you see what I'm doing wrong.

    sincerely,
    Johan

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Apr 07, 2014 @ 00:07
    Jan Skovgaard
    0

    Hi Johan

    I'm asuming you're running Umbraco 7.1 final.

    Have you tried having a look in the documentation on the new media cropper ? Image cropper

    Hope this helps.

    /Jan

  • Johan Plesner Hamann 105 posts 199 karma points
    Apr 07, 2014 @ 00:15
    Johan Plesner Hamann
    0

    yes I did, has it something to do with that it is a Macro? I've tried everything I can think of. 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Apr 07, 2014 @ 00:19
    Jan Skovgaard
    1

    Hi Johan

    What type of macro have you created? Is it a scripting file macro or a partial view macro?

    /Jan

  • Johan Plesner Hamann 105 posts 199 karma points
    Apr 07, 2014 @ 01:00
    Johan Plesner Hamann
    0

    scripting file macro in a template.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Apr 07, 2014 @ 09:03
    Jan Skovgaard
    101

    Hi Johan

    Ok, could you try just writing it in directly in the template? Or in a partial view macro?

    /Jan

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Apr 07, 2014 @ 10:14
    Jeavon Leopold
    2

    Hi Johan,

    As Jan has said, you need to use a MVC View (template), Partial View or a Partial View Macro.

    Generally you only need to use Views and Partial Views, Partial View Macros are mainly designed to be used when you need to select Macro in a RTE or you are using WebForms templates instead of MVC for some other reason (e.g. existing UserControl based code base)

    Scripting File Macro's are only in v7 for legacy support and should not be used except for upgraded websites.

    MVC templating documentation is here and documentation on Partial View Macros is here

    Hope that's helpful.

    Jeavon

  • Johan Plesner Hamann 105 posts 199 karma points
    Apr 07, 2014 @ 13:04
    Johan Plesner Hamann
    0

    Yes it works in razor template (of course) - so Thanks Jan.

    And I did not know not to use Scripting File Macro. I will look into Partial View. Thanks  Jeavon

    sincerely,
    Johan
Please Sign in or register to post replies

Write your reply to:

Draft