Skip to content

Instantly share code, notes, and snippets.

@greystate
Last active October 11, 2015 07:47
Show Gist options
  • Save greystate/3826435 to your computer and use it in GitHub Desktop.
Save greystate/3826435 to your computer and use it in GitHub Desktop.
Using CropUp and DAMP in Umbraco

Digibiz Advanced Media Picker

DAMP offers some great improvements for dealing with Media in Umbraco:

  • Editors can choose and/or create media right on the content item that needs it (don't have to create in Media before being able to select it)
  • Developers can have the Media XML saved right on the item, which makes it easier to use from XSLT (can't speak for Razor - would assume it's a little different)

Eksponent CropUp

The way CropUp does cropping is just magic (obviously, because Niels Kühnel is involved it's really a lot of math - but it's magic math, nonetheless :-)

  • You set a gravity point and CropUp just makes sure that that point is prominently included in the crops it delivers.

  • Any media item can be cropped on the fly (like with ImageGen) - you don't have to specifically create a cropping property if you're just using the default crops CropUp delivers.

  • CropUp comes with XSLT extensions that makes it a breeze to pull the desired crops from the media.

  • When you need to add or change existing crops you just do it. It doesn't affect your existing crops - if you ever used the standard Image Cropper on a real project, you know how huge this is!

A Typical Scenario

A Textpage in Umbraco has a pageImage property that points to a Media item.

On the page's own URL that image is a big wide banner, but if the page is featured on the front page of the site, we want to show a square thumbnail (with a link to the page of course).

In CropUp we set up banner and thumb crops - because we are pedantic about images, we know we may want to tweak a crop or two down the line, so we also create a cropping property on the media item as well - it's very simple as CropUp only needs to know the propertyalias of the uploaded file (which is almost always umbracoFile anyway).

NOTE: CropUp aliases must be all lowercase and can not contain spaces, dashes etc. (which actually makes great sense, since they end up as part of the URL). The Name you assign can be anything, though.

On the front page we have a Multi-Node Tree Picker (or that fancy new Widget Grid hotness!) to enable selecting pages for featuring.

Hmm... that's it, actually :-)

For the editors it's dead simple - they just choose a great photo/image when creating a page. If they need to, they can adjust the "gravitation" point, or maybe zoom a little into a crop, if necessary.

For the developers it's equally great because it's very easy to work with this combo (I use XSLT - wouldn't know about the Razor side, though I imagine it's equally good).

Caveats

There are a couple of things you currently can't do when using CropUp (instead of the standard Image Cropper) with DAMP:

  1. You can't choose a crop to show as the thumbnail
  2. You can't edit the crops when using the Edit button in DAMP (but you can disable the button on the DAMP data-type so your editors don't even know - they can always use the Open button)

Both are minor issues to our workflow but your mileage may of course vary.

UPDATE: These should be non-issues when DAMP v2.6 is out! Check the source repo if you need it now.

Feel free to bug me about any specifics to this! I'm greystate on twitter too :-)

/Chriztian Steinmeier

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