For a Umbraco 7.1 website i'm using the image cropper to crop gallery images.
My thumbnails works but when i click an image the image will be scalled bigger than the width of the image.
the code i'm using:
var largeImagePath = mediaChild.GetCropUrl(height: bigHeight, imageCropMode: ImageCropMode.Pad);
At the blog i've read that i need to use the ImageCropMode but when is set this to max it doens't work. The url still will be using the crop mode.
The problem is that i'm using not a width, only an height. With both specified the crops works but i only have the height because the images are not all the same width.
mediaChild has a cropper editor on the alias "umbracoFile"? You want
to get the image at a certain height but with the width being varied
depending on source?
yes the cropper has the alias umbracoFile.
yes that is correct. i want to load images from different sizes but with a max height of 600 px.
The code i've been using: (the mediaChild where the GetCropUrl is at is a media item)
Te above will work when i specify the height AND width, not just height or weight.
So in my situation it only takes the crop, but i want it to have a max width for scaling
example:
- image 1: 400 height, 300 width
- image 2: 100 height, 100 width
crop has max width of 200
image 1: 400 height, 200 width
image 2: 100 height 100 width (in my code this is smaller than the crop so it will be streched)
Hi Jeavon,
I've got a similar question - which may is stupid .. but I can't figure out how to get it to work. I normally use the slimsy package and create the crops with defined height and width in the code. There are no crops defined on the image, just using the focal point to position the center of all crops used. This works great with slimsy. But at some point I have the requirement to generate a normal Image-Url. With the standard methods described in the documentation I can't get the image Url with the correct crops generated using the focal point of the image.
Here is my actual code where I helped myself generating a URL without using the focal point:
@if(childPage.HasValue("images")){
var imageList= childPage.images.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var imageCollection = Umbraco.Media(imageList);
foreach (var myImageCrop in imageCollection)
{
var imageCropUrl = "http://www.mydomain.at"[email protected] + "?mode=crop&width=188&height=103&rnd=130794336420000000";
<img src="@imageCropUrl" >
}
ImageCropper ImageCropMode doesn't work
Hi,
For a Umbraco 7.1 website i'm using the image cropper to crop gallery images.
My thumbnails works but when i click an image the image will be scalled bigger than the width of the image.
the code i'm using:
At the blog i've read that i need to use the
ImageCropMode
but when is set this tomax
it doens't work. The url still will be using thecrop
mode.The problem is that i'm using not a width, only an height. With both specified the crops works but i only have the height because the images are not all the same width.
How to get this working?
reference: http://our.umbraco.org/forum/umbraco-7/using-umbraco-7/50182-Change-ImageCropMode-with-ImageCropper-has-no-effect
Hi Roy,
Can I just clarify a couple of things,
Assuming the above, did you try the solution in the other post?
Jeavon
Hi Jeavon,
yes the cropper has the alias umbracoFile. yes that is correct. i want to load images from different sizes but with a max height of 600 px.
The code i've been using: (the mediaChild where the GetCropUrl is at is a media item)
Ok, I think the above should work for you then?
Te above will work when i specify the height AND width, not just height or weight. So in my situation it only takes the crop, but i want it to have a max width for scaling
example:
Try this:
Make sure you have the following @usings at the top
FYI, I fixed this in Umbraco v7.1.2 so now if you specify a mode other than crop it doesn't crop
Hi Jeavon, I've got a similar question - which may is stupid .. but I can't figure out how to get it to work. I normally use the slimsy package and create the crops with defined height and width in the code. There are no crops defined on the image, just using the focal point to position the center of all crops used. This works great with slimsy. But at some point I have the requirement to generate a normal Image-Url. With the standard methods described in the documentation I can't get the image Url with the correct crops generated using the focal point of the image. Here is my actual code where I helped myself generating a URL without using the focal point:
Do you have any advice? Thanks a lot. Nora
Hi Nora,
I think you want something like this:
I don't think this is related to this existing thread at all though...?
Jeavon
Hi Nora,
why not to go simple way and use TypedMedia and extension method GetCropUrl()? Try below code (untested, but should work :)).
Thanks a lot to both of you! Would have been so easy ... I just didn't thought of changing to TypedMedia. Thank you :)
is working on a reply...