Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anthony Candaele 1197 posts 2049 karma points
    May 16, 2013 @ 14:51
    Anthony Candaele
    0

    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

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    May 16, 2013 @ 14:53
    Jeroen Breuer
    1

    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

  • Anthony Candaele 1197 posts 2049 karma points
    May 16, 2013 @ 14:55
    Anthony Candaele
    0

    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>

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    May 16, 2013 @ 15:02
    Jeroen Breuer
    100

    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

  • Anthony Candaele 1197 posts 2049 karma points
    May 16, 2013 @ 15:14
    Anthony Candaele
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft