Copied to clipboard

Flag this post as spam?

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


  • Kim Bantz Rasmussen 81 posts 310 karma points
    Apr 15, 2013 @ 09:14
    Kim Bantz Rasmussen
    0

    DAMP and value of custom property

    Hey,

    This is properly very easy to do but I can't get custom properties from my image. 

    My custom field in the image datatype is called Description. How can I show the value of that field?

    My code so far:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using DigibizAdvancedMediaPicker;
    
    
    @{
    
            if (Model.HasValue("backgroundImages")) {
                dynamic mediaItems = Model.backgroundImages.mediaItem;
                if (mediaItems.Count() > 1) {
                  foreach (var item in mediaItems) {
                    var image = item.Image;
                    <li><br />
                      @image.imageCropper.Find("@name", "background").url
                                     <br />
                      @image.Image.umbracoFile
                          <br />
                      <p>@image.Image.nodeName    </p>
    
                    </li>   
                  }  
                }
    
            }
            else {
                    @Html.Raw("")
    
            }                  
    
    }

    Umbraco 6.0.3

    Best regards
    Kim

     

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Apr 16, 2013 @ 12:47
    Jeroen Breuer
    0

    Hello,

    Did you try the following?

    var image = item.Image;
    var description = image.Description //which is the property alias.

    Jeroen

  • Kim Bantz Rasmussen 81 posts 310 karma points
    Apr 16, 2013 @ 13:24
    Kim Bantz Rasmussen
    0

    Hi Jeroen,

    Yes, but it didn't work :(

    Am I doing it wrong?: 

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using DigibizAdvancedMediaPicker;
    
    
    @{
    
            if (Model.HasValue("backgroundImages")) {
                dynamic mediaItems = Model.backgroundImages.mediaItem;
    
                if (mediaItems.Count() > 1) {
                  foreach (var item in mediaItems) {
                    var image = item.Image;
                    var description = image.Description;  
    
                    <li>
                      @image.imageCropper.Find("@name", "background").url
                      <p>@image.Image.nodeName</p>
    
                      <h1>@description</h1>
    
                    </li>   
                  }  
                }
    
            }
            else {
                    @Html.Raw("")
    
            }            
    } 
  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Apr 16, 2013 @ 13:33
    Jeroen Breuer
    100

    Usually the alias doesn't have a capital so try item.description.

    Jeroen

  • Kim Bantz Rasmussen 81 posts 310 karma points
    Apr 16, 2013 @ 13:52
    Kim Bantz Rasmussen
    0

    Thank you very much - that did the trick! 

    Best regards
    Kim
     

  • Craig100 1136 posts 2523 karma points c-trib
    Apr 23, 2013 @ 11:56
    Craig100
    0

    I have a similar situation. I added a "Caption" property to the Image mediaType. However, I can't get the caption out.  If I have theCaption = "Hello" it all works.

     

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using Eksponent.CropUp;
    @using DigibizAdvancedMediaPicker;
    @{
       if (Model.galleryImages.Any) {
       <div class="gallery">
               @foreach(dynamic image in Model.galleryImages){
                   var theThumbCrop = CropUp.GetUrl(image.File, new ImageSizeArguments { Width = 100, Height = 100, CropAlias = "thumbnail" });
                   var theFullCrop = CropUp.GetUrl(image.File, new ImageSizeArguments { Width = 800, Height = 600, CropAlias = "galleryMax" });
                   var theCaption = image.caption;
       <a href="@theFullCrop" rel="gallery1" class="fancybox" title="@theCaption"><img src="@theThumbCrop" width="100" height="100" alt="@theCaption"></a>
               }
            </div>    
       }
    }

    DAMP 2.5 Umb V6.0.3

    Cheers,

    Craig

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies