Explanation you have a root node and under that children with a property myMediaItem or what you call it.
foreach(var n in Model.Children) { var crop = @n.yourProperty.Find("@name","The name of the crop in the image Cropper data type").url <img src="@crop" alt=""> }
that's how i would use it. Tried a different other ways and that's the cleanest so far.
Or you could use the Digibiz Advanced Media Picker, there's a Helper Method with GetImageCropperUrl and so on. You could use the forum search our the project page from DAMP.
I've also been struggling with different methods to fetch crop data. Checking the crop's BaseElement works best for me:
@{ var image = Model.MediaById(<mediaid>); var crops = image.mediaCropper;// mediaCropper is the Image Cropper property I added to the Image media type
// check if specific crop exists if(crops.Find("@name","<cropname>").BaseElement!=null){ // crop exists <img src="@crops.Find("@name","<cropname>").url" alt="@image.Name"/> } else{ // crop doesn't exist, use alternative method (e.g. ImageGen) } }
I've also been struggeling for a while with the cropped images using DAMP. Sometimes the solution is so easy - I simply did not realize that mediaCropper is the name of the image cropper property ... thanks at Arjan H. for the comment. Maybe it would be helpful to include this in the razor examples.
Using non-MVC Razor I'm trying to cycle through child pages getting one of three images from each page and a particular crop. Using DAMP 2.5 (storing ID) and Umb 6.0.3.
thx for the codes above provided by you guys .I have ever did the work in my way .check sample codes of image cropping using RasterEdge.Imaging.Basic; using RasterEdge.Imaging.Basic.Core; using RasterEdge.Imaging.Processing; using RasterEdge.Imaging.Basic.Codec;
namespace RE__Test { publicpartialclass Form1 : Form { public Form1() { InitializeComponent(); }
Media Image Crop with razor
I've seen a few threads around about this, but nothing looks ideal.
I have a content node with an image property. All i want to do is get a crop of that image with a specified name. What is the best way of doing this?
uQuery extension? DynamicMedia? my own helper function?
Okay best way is to use the new .Find.
1st go to http://nightly.umbraco.org/umbraco%204.7/4.7%20RC/ download the latest 4.7.1 and copy the umbraco.MacroEngines.dll to your existing install for testing.
2nd you can now acces with the following code.
Explanation you have a root node and under that children with a property myMediaItem or what you call it.
foreach(var n in Model.Children)
{
var crop = @n.yourProperty.Find("@name","The name of the crop in the image Cropper data type").url
<img src="@crop" alt="">
}
that's how i would use it. Tried a different other ways and that's the cleanest so far.
Or you could use the Digibiz Advanced Media Picker, there's a Helper Method with GetImageCropperUrl and so on. You could use the forum search our the project page from DAMP.
I've also been struggling with different methods to fetch crop data. Checking the crop's BaseElement works best for me:
I'm using the Digibiz Advanced Media Picker
The way I check for a crop is like this:
@if (Model.HasValue("conferenceImage") && Model.conferenceImage.Count() >0)
{
var imageCrop = DAMP_Helper.GetImageCropperUrl(Model.conferenceImage, "conferenceCrop");
<img src="@imageCrop" alt="@Model.Name"/>
}
Hope this helps,
Anthony
I've also been struggeling for a while with the cropped images using DAMP. Sometimes the solution is so easy - I simply did not realize that mediaCropper is the name of the image cropper property ... thanks at Arjan H. for the comment. Maybe it would be helpful to include this in the razor examples.
Nora
Using non-MVC Razor I'm trying to cycle through child pages getting one of three images from each page and a particular crop. Using DAMP 2.5 (storing ID) and Umb 6.0.3.
articleListImage is the propertyAlias of the DAMP control.
articleList is the name of the crop required.
Everything appears on the page but the images!
I've tried @foreach (dynamic image in Model.articleListImage) and@foreach (dynamic image in childPage.articleListImage)to no avail.
Any hints as to the correct syntax would be gratefully received.
Craig
I'm currently using the following helper class to fetch a crop:
http://pastebin.com/raw.php?i=J6JFJtd2
Save this code in UmbracoHelper.cshtml and place the file in your App_Code directory.
Example of usage:
I have spent an hour going through the Cultiv razor samples and trying to replicate the examples on another site.
However the cultiv examples refer to a Data Type called DAMP 2.0 (Full Media).
I have replicated the settings exactly on my site refering to a alias of mediaCropper in the display options.
I can't figure where this value "media cropper" is referenced. Its not a Data type or a document type.
Its not obvious how this all ties together.
Also on the Cultiv site when editting a damp control there is a Crop tab which I don't get.
Have I missed a step here?
Any help would be appreciated.
FOUND IT- IGNORE ME
is working on a reply...