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="" />
</a>
<p>@id.Name</p>
</div>
}
</div>
}
Working pre 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 (string id in ids )
{
int imageId = int.Parse(id);
<div class="col-md-4">
<a href="@Umbraco.Media(imageId).Url" data-fancybox="group" data-caption="@Umbraco.Media(imageId).Name">
<img src="@Umbraco.Media(imageId).GetCropUrl("umbracoFile","square")" alt="" />
</a>
<p>@Umbraco.Media(imageId).Name</p>
</div>
}
</div>
}
Comments
Post a Comment