Skip to content

Instantly share code, notes, and snippets.

@Jeavon
Created June 6, 2014 08:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jeavon/0bfa4c82a0dd43ff2c52 to your computer and use it in GitHub Desktop.
Save Jeavon/0bfa4c82a0dd43ff2c52 to your computer and use it in GitHub Desktop.
GetCropUrl - check for predefined and fall back if not
@{
if (feature.HasValue("Image"))
{
var featureImage = Umbraco.TypedMedia((int)feature.Image);
var myCropUrl = featureImage.GetCropUrl("PageBannerCrop") ?? featureImage.GetCropUrl(200, 100);
<a href="@feature.Url" class="image image-full"><img src="@myCropUrl" alt="" /></a>
}
}
@jesperordrup
Copy link

Thanks - completely useful. And I've wrapped it in: EnsureCrop() which takes a defaultImgPath too. Thanks again!

@akeilox
Copy link

akeilox commented Oct 8, 2014

Hi Jeavon
Is there a way to change the black background added on non-aspect ratio resize of the image, assuming some sort of settings with image resizing but cant locate it. i would like to change that black default to white. any ideas?

@Jeavon
Copy link
Author

Jeavon commented Oct 29, 2014

@akeilox yes there is, hope you found the answer elsewhere already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment