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
    May 25, 2017 @ 13:00
    Jonathan Roberts
    0

    Umbraco GetCropUrl is empty

    Hi,

    I am using the image cropper in the Image MediaType. The majority of the images are coming through but there are a handful where they are not. I have tried a variety of different code examples (see below) but to no avail.

    This is the code I am using: Get all Images from a folder in Media section:

     var folder = Umbraco.TypedMediaAtRoot().DescendantsOrSelf("Folder").Where(x => x.Id == CurrentPage.officerImages).FirstOrDefault();
                            var images = folder.Children(x => x.DocumentTypeAlias == "Image").RandomOrder();
    

    Then I loop the Images to display them online. I have included all the test examples that some work and others dont.

    if (folder != null)
                {
                    <div class="officers">
                        @foreach (var img in images)
                        {
                            if (img.ContentType.Alias == "Image")
                            {
    
    
                                var m = Umbraco.TypedMedia(img.Id); //works for ALL images
                                var cropUrl = m.GetCropUrl("umbracoFile", "NPT profile pic"); //DOES NOT WORK FOR ALL IMAGES
                                <div class="item" style="width:100px;">
                                    <div class="hide">@img.GetPropertyValue("umbracoFile")</div>//works for ALL images
                                    <img src="@cropUrl" alt="@img.GetPropertyValue("imgTitle")" class="img-responsive" /><br /><strong>@img.GetPropertyValue("imgTitle")</strong>//DOES NOT WORK FOR ALL IMAGES
                                    @*<img src="@img.GetPropertyValue("umbracoFile")" alt="@img.GetPropertyValue("imgTitle")" class="img-responsive" /><br /><strong>@img.GetPropertyValue("imgTitle")</strong>*@//works for ALL images
                                </div>
                            }
                        }
                    </div>
                }
    

    Is this a bug or am I doing this wrong?

    Thanks Jon

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    May 25, 2017 @ 14:14
    Alex Skrypnyk
    0

    Hi Jon

    What version of Umbraco are you using?

  • Jonathan Roberts 409 posts 1063 karma points
    May 25, 2017 @ 14:15
    Jonathan Roberts
    0

    Umbraco version 7.4.3 assembly: 1.0.5948.18141

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    May 25, 2017 @ 14:17
    Alex Skrypnyk
    0

    Jon

    You need only "NPT profile pic", remove "umbracoFile" param please.

    var cropUrl = m.GetCropUrl("NPT profile pic"); 
    
  • Jonathan Roberts 409 posts 1063 karma points
    May 25, 2017 @ 14:19
    Jonathan Roberts
    0

    Hi,

    I had already tried that way but it didnt work. I was trying to look in the database to see if the crop values had been saved but I have no idea where to start looking.

    Jon

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    May 25, 2017 @ 14:20
    Alex Skrypnyk
    0

    try this one:

    var cropUrl = m.GetCropUrl("crop alias"); 
    
  • Jonathan Roberts 409 posts 1063 karma points
    May 25, 2017 @ 16:27
    Jonathan Roberts
    0

    Hi, why would that work?

  • Jonathan Roberts 409 posts 1063 karma points
    May 25, 2017 @ 14:21
    Jonathan Roberts
    0

    All the images disappear

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    May 25, 2017 @ 16:34
    Alex Skrypnyk
    0

    Hi Jon

    What is an alias of your crop?

    Do you see images if you render urls like usual medias?

    Alex

  • Jonathan Roberts 409 posts 1063 karma points
    May 26, 2017 @ 06:54
    Jonathan Roberts
    0

    Hi,

    The alias is above - "NPT profile pic".

    Yes the images appear if I use the original way:

    <img src="@img.GetPropertyValue("umbracoFile")" alt="@i**mg.GetPropertyValue("imgTitle")**" class="img-responsive" /><br /><strong>@img.GetPropertyValue("imgTitle")</strong>
    

    Unfortunately we need to use the Cropper.

    Thanks for your help with this.

  • Jonathan Roberts 409 posts 1063 karma points
    May 25, 2017 @ 14:33
    Jonathan Roberts
    0

    Is there anything in the database that I could look at?

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Oct 01, 2020 @ 09:52
    Alex Skrypnyk
    0

    Hi Jonathan,

    We have the same issue, all images do not work, do you have any idea why it could happen?

    Thanks, Alex

  • Micha Somers 134 posts 597 karma points
    May 26, 2017 @ 15:38
    Micha Somers
    0

    Hi Jonathan,

    Some questions, hopefully to get some ideas where to search for a solution...

    You mentioned that a handful images are not coming through.

    Do you know which ones exactly?

    If so, what type of images are the problematic ones (eg. jpg/png/...)?

    Have you migrated to a newer version of Umbraco since the images been have been added?

    Did you try to remove and re-add one of those images to see if that results in showing that image again?

    Best regards, Micha

Please Sign in or register to post replies

Write your reply to:

Draft