Copied to clipboard

Flag this post as spam?

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


  • AndreasFurster 12 posts 83 karma points
    Oct 31, 2016 @ 15:05
    AndreasFurster
    0

    Get media name from cropped image

    Hi everyone,

    I'm a little while working with Umbraco for now. New to the forums :)

    I've a templating problem with the Cropped Image DataType. How can I get the media's name?

    The only thing I get from the property is:

    {
      "focalPoint": {
        "left": 0.5,
        "top": 0.5
      },
      "src": "/media/1071/stack.png",
      "crops": [
        {
          "alias": "Logo",
          "width": 240,
          "height": 240
        }
      ]
    }
    

    How can I get the other media properties like it's name?

  • Comment author was deleted

    Oct 31, 2016 @ 15:41

    Hi Andreas, so you have a cropper property directly on your doc type? Then it makes sense that that is all that gets stored since you aren't using a media picker...

  • AndreasFurster 12 posts 83 karma points
    Oct 31, 2016 @ 15:46
    AndreasFurster
    0

    Hi Tim,

    Yeah that's what I do. Is there an alternative?
    The backend user must crop the image.

    Thanks, Andreas Furster

  • Comment author was deleted

    Oct 31, 2016 @ 15:47

    You could change the media type, to use cropper instead of upload for it's images, then use a media picker on your doc type, that will store the id and you will be able to fetch the name then

  • AndreasFurster 12 posts 83 karma points
    Oct 31, 2016 @ 15:59
    AndreasFurster
    0

    I don't get this right.

    I added an new Media type with the image cropper. But if I use a media picker in my doc type, I can't choose which media type it has to use, so there is no cropper in the document editor.

    What am I missing?

  • Comment author was deleted

    Oct 31, 2016 @ 16:01

    Sorry should have been a bit more specific, you don't need to add a new media type but change the existing media type, change the property umbraco file to imagecropper instead of upload (if it isn't already)

  • AndreasFurster 12 posts 83 karma points
    Oct 31, 2016 @ 16:05
    AndreasFurster
    0

    You mean the default image media type? That it's an image cropper already.

    And if I add a crop size there, all media pickers will use that right? That's not what I want.

  • Comment author was deleted

    Oct 31, 2016 @ 16:14

    Ok think I misunderstood your question, you just want to output the alt text for an image you get from the cropper I suppose?

  • AndreasFurster 12 posts 83 karma points
    Oct 31, 2016 @ 16:26
    AndreasFurster
    0

    Yeah, you'r right! I'm sorry I did not note that.

  • Comment author was deleted

    Oct 31, 2016 @ 16:28

    Well if the image cropper doesn't provide you the name you could just add a new property to hold that no?

  • AndreasFurster 12 posts 83 karma points
    Oct 31, 2016 @ 18:35
    AndreasFurster
    0

    Yeah, I could. But then i've to do this for every image. (About 20 in the document type)

    But why if the media type already contains a name? I noticed I could even use regex on "src": "/media/1071/stack.png", to get the media id.

    I was just wondering if there wasn't an more efficient way of getting the id or name.

Please Sign in or register to post replies

Write your reply to:

Draft