Skip to main content

Posts

Showing posts from 2018

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
@if(CurrentPage.HasValue("galleryImages"))
                    {
                        <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="" />
                     …