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>
}
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.
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:
Then I loop the Images to display them online. I have included all the test examples that some work and others dont.
Is this a bug or am I doing this wrong?
Thanks Jon
Hi Jon
What version of Umbraco are you using?
Umbraco version 7.4.3 assembly: 1.0.5948.18141
Jon
You need only "NPT profile pic", remove "umbracoFile" param please.
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
try this one:
Hi, why would that work?
All the images disappear
Hi Jon
What is an alias of your crop?
Do you see images if you render urls like usual medias?
Alex
Hi,
The alias is above - "NPT profile pic".
Yes the images appear if I use the original way:
Unfortunately we need to use the Cropper.
Thanks for your help with this.
Is there anything in the database that I could look at?
Hi Jonathan,
We have the same issue, all images do not work, do you have any idea why it could happen?
Thanks, Alex
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
is working on a reply...