Skip to main content


Recent posts

Umbraco 7 Get Image Crop from Media ID for specific image,simple version razor sniper

In Umbraco 7 to get a image crop from a image media item in the media folder, suppply the Media id number and the name of the image crop:

 <img src="@Umbraco.Media(1297).GetCropUrl("umbracoFile","imageCropName")" class="img-responsive">

Umbraco 7 Get Crops from Multi Media Picker for Image Gallery

Working in 7.9.2:

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
                        <div class="row">

                            char[] splitChar = { ',' };
                            string[] ids = CurrentPage.galleryImages.ToString().Split(splitChar, StringSplitOptions.RemoveEmptyEntries);
                            @foreach (var id in CurrentPage.galleryImages )
                        int imageId = int.Parse(id.ToString());
                            <div class="col-md-6">
                               <a href="@id.Url" data-fancybox="group" data-caption="@id.Name">
                                    <img src="@Umbraco.Media(@imageId).GetCropUrl("umbracoFile","square")" alt="" />

Umbraco 7 Get Media images by ID when using the Multi Media Picker to display a Gallery

Umbraco 7 Get Media images by ID when using the Multi Media Picker

This is usefull when creating a gallery of images.

1) In your Doctype add the Multiple Media Picker

2) Umbraco 7 Razor code snippet partial:

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@helper RemoveExtensions(string stringIn)
 var thisTitle = stringIn;
                                        thisTitle = thisTitle.Replace(".jpg", "");
                                        thisTitle = thisTitle.Replace(".png", "");
                                        thisTitle = thisTitle.Replace(".jpeg", "");
                                        thisTitle = thisTitle.Replace(".gif", "");
                                        thisTitle = thisTitle.Replace(".bmp", "");
                                        thisTitle = thisTitle.Replace("-", " ");
                                        thisTitle = thisT…

Convert an SDF file to a MDF - File useful for Umbraco 7

How to convert a SDF Compact Database file to a full blown SQL Server MDF file.

PART ONE (change the SDF file to MDF file): a) Install SQL Server Compact Toolbox runtime

b) Start SQL Server Compact Toolbox runtime

c) Select Add and Browse to the SDF file that you want to convert

d) Select Sctipt Database Scheme and Data (this will produce a script)

PART TWO (import the database in to SQL Server
Management Studio)

a) In SQL Server Management Studio create a Blank Database

b) Right Click on the new database and select New Query

c) Paste in the script and press execute: this will create all the Umbraco tables.

Now you just need to update your umbraco config file to point to the new database.

Umbraco 7 Tag and Sorting Tags in to Alphabetical Order Using a Dictionary

Umbraco 7 Tag and Sorting Tags in to Alphabetical Order Using a Dictionary:

    Dictionary<string, int> tagsList =
            new Dictionary<string, int>();
 @foreach (var c in CurrentPage.Children())

           foreach (var item in c.GetPropertyValue<string[]>("tags"))
                if (!tagsList.ContainsKey(item))
                    tagsList.Add("" + item, 1);


     var ordered = tagsList.OrderBy(x => x.Key);

                foreach(var i in ordered)
                 <li class="filterLink"><a href="@i.Key">@i.Key</a></li>
                <!--<li class="filterLink"><a href="">item</a></li>-…