I have some problem with crop function. I'm using a nested Multiple Node Tree Picker, but the GetCropUrl doesn't work. The crop function is ok, I've already used it.
@{ if (CurrentPage.HasValue("artists")) { var artistList = CurrentPage.artists.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); var artistCollection = Umbraco.Content(artistList); foreach (var artist in artistCollection) { if (artist.HasValue("coverImages")) { var coverImagesList = artist.coverImages.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); var coverImagesCollection = Umbraco.Media(coverImagesList); foreach (var coverImage in coverImagesCollection.RandomOrder().Take(1).Where("Visible")) { <img src="@coverImage.GetCropUrl(305, 195)"/> } } } } }
GetCropUrl problem within nested foreach
I have some problem with crop function. I'm using a nested Multiple Node Tree Picker, but the GetCropUrl doesn't work. The crop function is ok, I've already used it.
So if you change to:
Does it work although with the original images?
Yes, it works with the original images.
Ok, what HTML is rendered when you set it back to GetCropUrl?
Sorry, how do you mean "what HTML"? I don't understand.
I noticed something, but I don't understand. I started to use Id.
When I use this:
I got back the the image id from @coverImage.Id, and the image is working.
When I use this:
The image is still good.
After I'm cropping with fix id.
Working, but then:
I got an error:
'Umbraco.Web.Models.PublishedContentBase' does not contain a definition for 'GetCropUrl'
How is that possible? I'm not professional with this.
Hi Levente,
Could you post how
coverImage
is defined?I could take a guess and say that coverImage.Id is dynamic so then try this:
Jeavon
Yes, you were right! (int)coverImage.Id helped, now it's working perfectly.
Thank you so much your help, I really appreciate it.
You're welcome!
is working on a reply...