Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I installed DAMP 2.5 on an Umbraco 4.11.8 instance.
I trying to access an image crop using this Razor syntax
@if (item.HasValue("staffImage") && item.staffImage.Count() > 0)
{
var staffCrop = DAMP_Helper.GetImageCropperUrl(item.staffImage, "staffCrop");
<img class="scale-with-grid shadow member" src="@staffCrop" alt="@item.Name"/>
}
this code work on my websites where I use DAMP 2.0
But now it isn't working anymore. Has something change since DAMP 2.5 ?
Thanks for your help,
Anthony
It should still work on DAMP 2.5 if you're using Razor in a macro (it's different in MVC). What error do you get?
Jeroen
Hi Jeroen,
I'm getting a null reference exception:
Object reference not set to an instance of an object
My xml in Umbraco.config looks like this:
<staffImage>
<DAMP fullMedia="">
<mediaItem>
<StaffImage id="1088" version="f7c963f2-7849-4e75-b94d-f080ca560062" parentID="1084" level="3" writerID="0" nodeType="1085" template="0" sortOrder="0" createDate="2013-05-15T11:28:26" updateDate="2013-05-15T11:29:02" nodeName="sami" urlName="sami" writerName="admin" nodeTypeAlias="StaffImage" path="-1,1082,1084,1088">
<umbracoFile>/media/251/sami.jpg</umbracoFile>
<umbracoWidth>150</umbracoWidth>
<umbracoHeight>129</umbracoHeight>
<umbracoBytes>6450</umbracoBytes>
<umbracoExtension>jpg</umbracoExtension>
<staffCrop>
<crops date="2013-05-15T11:28:26">
<crop name="staffCrop" x="10" y="0" x2="139" y2="129" />
</crops>
</staffCrop>
</StaffImage>
</mediaItem>
</DAMP>
</staffImage>
Looks like the crop in your xml is missing the url attribute. It should looks like this:
<crop name="ProductDetail" x="175" y="0" x2="625" y2="450" url="/media/4973/image_ProductDetail.jpg" />
That's not related to DAMP. I don't know why it's missing that.
That was indeed the problem.
I removed the image, then picked it again with DAMP, made a new crop and saved it, and now the xml is correct:
<crop name="staffCrop" x="10" y="0" x2="139" y2="129" url="/media/251/sami_staffCrop.jpg" />
thanks for your help,
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Razor code not working in DAMP 2.5
Hi,
I installed DAMP 2.5 on an Umbraco 4.11.8 instance.
I trying to access an image crop using this Razor syntax
@if (item.HasValue("staffImage") && item.staffImage.Count() > 0)
{
var staffCrop = DAMP_Helper.GetImageCropperUrl(item.staffImage, "staffCrop");
<img class="scale-with-grid shadow member" src="@staffCrop" alt="@item.Name"/>
}
this code work on my websites where I use DAMP 2.0
But now it isn't working anymore. Has something change since DAMP 2.5 ?
Thanks for your help,
Anthony
It should still work on DAMP 2.5 if you're using Razor in a macro (it's different in MVC). What error do you get?
Jeroen
Hi Jeroen,
I'm getting a null reference exception:
Object reference not set to an instance of an object
My xml in Umbraco.config looks like this:
<staffImage>
<DAMP fullMedia="">
<mediaItem>
<StaffImage id="1088" version="f7c963f2-7849-4e75-b94d-f080ca560062" parentID="1084" level="3" writerID="0" nodeType="1085" template="0" sortOrder="0" createDate="2013-05-15T11:28:26" updateDate="2013-05-15T11:29:02" nodeName="sami" urlName="sami" writerName="admin" nodeTypeAlias="StaffImage" path="-1,1082,1084,1088">
<umbracoFile>/media/251/sami.jpg</umbracoFile>
<umbracoWidth>150</umbracoWidth>
<umbracoHeight>129</umbracoHeight>
<umbracoBytes>6450</umbracoBytes>
<umbracoExtension>jpg</umbracoExtension>
<staffCrop>
<crops date="2013-05-15T11:28:26">
<crop name="staffCrop" x="10" y="0" x2="139" y2="129" />
</crops>
</staffCrop>
</StaffImage>
</mediaItem>
</DAMP>
</staffImage>
Looks like the crop in your xml is missing the url attribute. It should looks like this:
<crop name="ProductDetail" x="175" y="0" x2="625" y2="450" url="/media/4973/image_ProductDetail.jpg" />
That's not related to DAMP. I don't know why it's missing that.
Jeroen
That was indeed the problem.
I removed the image, then picked it again with DAMP, made a new crop and saved it, and now the xml is correct:
<crop name="staffCrop" x="10" y="0" x2="139" y2="129" url="/media/251/sami_staffCrop.jpg" />
thanks for your help,
Anthony
is working on a reply...