Copied to clipboard

Flag this post as spam?

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


  • Christian Winther 3 posts 23 karma points
    Oct 15, 2014 @ 12:10
    Christian Winther
    0

    Macro with simple gallery or lightbox in RTE

    I'm trying to make a super simple gallery in a macro after having given up on creating a mediapicker which automatically creates a link to the image in a popup eg. lightbox.

    My macro gallery works but every time i save and try to edit my article the macro is supposedly gone. In the source it is still there but missing some brackets.

    My macro looks like this:

    @using Umbraco.Web.Models
    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{
       
     var imagesString = Model.MacroParameters["images"];
        var imagesSplit = imagesString.ToString().Split(',');
     var count = 0;
     
     <div class="theme_quickGallery_wrap theme_macro mp_gallery" style="display:table-row">
      
     @foreach(var imageId in imagesSplit)
     {
      var umbFile = Umbraco.TypedMedia(imageId);
      var imgTitle = Umbraco.Media(imageId).Name;
      var imgPath = umbFile.Url;
      if (umbFile != null) {
       var dFocalLeft = 50.0;
                var dFocalTop = 50.0;
                dynamic imageInfo = Umbraco.Media(Convert.ToInt32(imageId)).umbracoFile;
                if(imageInfo.focalPoint != null){
                    dFocalLeft = imageInfo.focalPoint.left.Value * 100;
                    dFocalTop = imageInfo.focalPoint.top.Value * 100;
                }  
       
       var imgPathCropped = "";
                imgPathCropped = Umbraco.TypedMedia(Convert.ToInt32(imageId)).GetCropUrl("Gallerithumbnail");
                if(imgPathCropped == null)
                {
                    imgPathCropped = Umbraco.TypedMedia(Convert.ToInt32(imageId)).GetCropUrl(propertyAlias: "images", width: 150, height: 150, imageCropMode: ImageCropMode.Crop);
                }
       
       <a class="theme_quickGallery_thumbWrap" href="@imgPath" title="@imgTitle">
        <div class="theme_quickGallery_thumb" style="background-image: url(@imgPathCropped);background-position-x: @dFocalLeft%; background-position-y:@dFocalTop%;"></div>
        </a>
       }
      }
     </div>
    }

    Please help

     

Please Sign in or register to post replies

Write your reply to:

Draft