Copied to clipboard

Flag this post as spam?

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


  • Toni Becker 146 posts 425 karma points
    Apr 11, 2011 @ 14:15
    Toni Becker
    1

    @Jeroen - Snippet done - read more inside

    Hy Jeroen and sorry for my long abstinence.

    I've manged to handle with the media picker and cropped images at once and yes the snippet supports multiple pictures and crops in one instance.

    Here comes the code:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using umbraco.MacroEngines;
    @using System.Linq;

    @foreach(dynamic img in Model.Children)
    {
        if(img.imgUpload.ToString() != "")
        {
            foreach(dynamic d in img.imgUpload.mediaItem)
            {
                if(d.BaseElement.Name == "Image")
                {
                    <img src="@d.umbracoFile" />
            foreach(dynamic c in d.thumbnails.crops)
            {
            if(c.name == "small")
            {
                <img src="@c.url" />
            }
        }
                }
                else
                {
                    <img src="@d.Image.umbracoFile" />
                    foreach(dynamic c2 in d.Image.thumbnails.crops)
                    {
                        if(c2.name == "small")
                        {
                            <img src="@c2.url" />
                        }

                    }
                }
            }
        }
        else
        {
            <span>Keine Bilder vorhanden</span>
        }
    }

    And here's a screenshot rendering the whole thing :

    Have FUN !!!! :)

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Apr 11, 2011 @ 14:20
    Jeroen Breuer
    0

    Hi Toni,

    Thanks for the snippet! I'll try it out soon.

    Jeroen

  • Toni Becker 146 posts 425 karma points
    Apr 11, 2011 @ 14:27
    Toni Becker
    0

    hehe okay.

    Am nice to know is my sitestructe:

    I've created a doctype imagerender and inside this i've created a doctype imagePlaceholder.
    The Placeholder holds the property imgUpload (in this case the DAMP).

    Than i've created in the Developersection a new script razor cshtml and include this one into my template with the Doctype Imagerender

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Apr 27, 2011 @ 10:52
    Jeroen Breuer
    0

    The sample provided is nice, but is also shows some of the problems of Razor. There are a lot of if statements in it, where in xslt none would be required to do the same. Here is an XPath sample:

    $currentPage/sliderImage/DAMP [@fullMedia]/mediaItem/Image/croppedImages/crops/crop[@name='SliderImage']/@url

    I know XPath can also be used in Razor, but that's cheating ;-). Somehow it would already be a lot easier if the first node wasn't removed like it says here. Can that be disabled somehow?

    Jeroen

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Apr 28, 2011 @ 17:47
    Jeroen Breuer
    0

    In the latest change set I've created a helper method to get the crop url in razor. That way you don't need to loop through all the crops. Here is a small sample:

    <img src="@DAMP_Helper.GetImageCropperUrl(node.background.mediaItem, "slider")" />

    Jeroen

  • Toni Becker 146 posts 425 karma points
    Apr 28, 2011 @ 18:43
    Toni Becker
    0

    n1 jeroen would be very usefull for future projects thumbs up

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    May 04, 2011 @ 14:57
    Jeroen Breuer
    0

    Just want to add some more info to this topic. The xml used for the razor sample probably looks something like this:

    <images>
      <DAMP fullMedia="">
        <mediaItem>
          <Image id="1220" version="994f1f35-8b7e-41b7-b815-b806b2dc8689" parentID="1043" level="2" writerID="0" nodeType="1032" template="0" sortOrder="7" createDate="2010-11-09T22:06:45" updateDate="2010-11-09T22:06:30" nodeName="RLZ_referenties_Kewlox_logo_101109.gif" urlName="rlz_referenties_kewlox_logo_101109.gif" writerName="Administrator" nodeTypeAlias="Image" path="-1,1043,1220">
            <umbracoFile>/media/1220/RLZ_referenties_Kewlox_logo_101109.gif</umbracoFile>
            <umbracoWidth>318</umbracoWidth>
            <umbracoHeight>102</umbracoHeight>
            <umbracoBytes>4526</umbracoBytes>
            <umbracoExtension>gif</umbracoExtension>
            <resized>/media/1220/RLZ_referenties_Kewlox_logo_101109_resized.gif</resized>
            <croppedImages>
              <crops date="18/11/2010 15:39:57">
                <crop name="HeaderImage" x="47" y="0" x2="789" y2="256" url="/media/1220/RLZ_referenties_Kewlox_logo_101109_resized_HeaderImage.jpg" />
                <crop name="small" x="0" y="0" x2="195" y2="256" url="/media/1220/RLZ_referenties_Kewlox_logo_101109_resized_SliderImage.jpg" />
                <crop name="Testimonial" x="319" y="0" x2="771" y2="240" url="/media/1220/RLZ_referenties_Kewlox_logo_101109_resized_Testimonial.jpg" />
              </crops>
            </croppedImages>
            <nlName>KewLox logo</nlName>
          </Image>
        </mediaItem>
        <mediaItem>
          <Image id="1221" version="884f1f35-8b7e-41b7-b815-b806b2dc8689" parentID="1043" level="2" writerID="0" nodeType="1032" template="0" sortOrder="8" createDate="2010-11-09T22:06:46" updateDate="2010-11-09T22:06:36" nodeName="RLZ_test.gif" urlName="rlz_test.gif" writerName="Administrator" nodeTypeAlias="Image" path="-1,1043,1221">
            <umbracoFile>/media/1221/RLZ_test.gif</umbracoFile>
            <umbracoWidth>319</umbracoWidth>
            <umbracoHeight>103</umbracoHeight>
            <umbracoBytes>4560</umbracoBytes>
            <umbracoExtension>gif</umbracoExtension>
            <resized>/media/1221/RLZ_test_resized.gif</resized>
            <croppedImages>
              <crops date="18/11/2010 15:39:57">
                <crop name="HeaderImage" x="47" y="0" x2="789" y2="256" url="/media/1221/RLZ_referenties_test_resized_HeaderImage.jpg" />
                <crop name="small" x="0" y="0" x2="195" y2="256" url="/media/1221/RLZ_referenties_test_resized_SliderImage.jpg" />
                <crop name="Testimonial" x="319" y="0" x2="771" y2="240" url="/media/1221/RLZ_referenties_test_resized_Testimonial.jpg" />
              </crops>
            </croppedImages>
            <nlName>Test</nlName>
          </Image>
        </mediaItem>
      </DAMP>
    </images>

    Jeroen

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    May 05, 2011 @ 15:07
    Jeroen Breuer
    0

    I've posted this problem in another topic since it's not just related to DAMP, but to all DynamicXml: http://our.umbraco.org/forum/developers/razor/20024-Root-node-removed-problem-in-DynamicXml.

    Jeroen

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    May 12, 2011 @ 12:59
Please Sign in or register to post replies

Write your reply to:

Draft