Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I'm trying to use image cropper from the new Media Picker. My Image Media Types are Image croppers. But I could not figure it out using dynamic content in an helper.
My code is as follows:
@helper yayinGetirYeni(dynamic yayin) { <div class="entry clearfix"> @if (yayin.HasValue("listeGorseli")) { var image = yayin.listeGorseli; var cropUrl = image.GetCropUrl("liste"); <div class="entry-image"> <a href="@yayin.Url"><img src="@cropUrl" /></a> </div> } <div class="entry-title"> <h2><a href="@yayin.Url">@yayin.Name</a></h2> </div> </div> }
Thanks
Hi Bora
Do not use dynamics )) Best practice is to use strongly typed models in Umbraco.
Thanks,
Alex
Please, show all your view code, we will find a problem together.
Hi Alex,
my whole code is like that:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ Layout = "Master.cshtml"; var blog = CurrentPage.Children.Where("Visible").OrderBy("createDate desc"); var pageSize = 8; var previousPageIsEllipsis = false; var page = 1; int.TryParse(Request.QueryString["page"], out page); var items = blog; var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize); if (page > totalPages) { page = totalPages; } else if (page < 1) { page = 1; } } @foreach (var item in blog.Skip((page - 1) * pageSize).Take(pageSize)) { @yayinGetirYeni(item); } @helper yayinGetirYeni(dynamic yayin) { <div class="entry clearfix"> @if (yayin.HasValue("listeGorseli")) { var image = yayin.listeGorseli; var cropUrl = image.GetCropUrl("liste"); <div class="entry-image"> <a href="@yayin.Url"><img src="@cropUrl" /></a> </div> } <div class="entry-title"> <h2><a href="@yayin.Url">@yayin.Name</a></h2> </div> <ul class="entry-meta clearfix"> <li><i class="icon-calendar3"></i> @yayin.CreateDate.ToString("dd MMMM yyyy")</li> </ul> <div class="entry-content"> <p>@yayin.haberSpotYazi</p> <a href="@yayin.Url" class="more-link">Daha Fazlası</a> </div> </div> }
Thanks for your help
I would rewrite this code like that:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ Layout = "Master.cshtml"; var blog = Umbraco.AssignedContentItem.Children.Where(x => x.IsVisible()).OrderByDescending(x => x.CreateDate); var pageSize = 8; var previousPageIsEllipsis = false; int page; int.TryParse(Request.QueryString["page"], out page); var items = blog; var totalPages = (int)Math.Ceiling(items.Count() / (double)pageSize); if (page > totalPages) { page = totalPages; } else if (page < 1) { page = 1; } } @foreach (var item in blog.Skip((page - 1) * pageSize).Take(pageSize)) { @yayinGetirYeni(item); } @helper yayinGetirYeni(IPublishedContent yayin) { <div class="entry clearfix"> @if (yayin.HasValue("listeGorseli")) { var cropUrl = yayin.GetCropUrl("listeGorseli", "liste"); <div class="entry-image"> <a href="@yayin.Url"><img src="@cropUrl" /></a> </div> } <div class="entry-title"> <h2><a href="@yayin.Url">@yayin.Name</a></h2> </div> <ul class="entry-meta clearfix"> <li><i class="icon-calendar3"></i> @yayin.CreateDate.ToString("dd MMMM yyyy")</li> </ul> <div class="entry-content"> <p>@yayin.GetPropertyValue("haberSpotYazi")</p> <a href="@yayin.Url" class="more-link">Daha Fazlas</a> </div> </div> }
Did you solve the issue?
Share with the community, please.
Thank you very much Alex. This solved it.
If you change your dynamic to IPublishedContent, you can then use this:
@helper yayinGetirYeni(IPublishedContent yayin) { <div class="entry clearfix"> @if (yayin.HasValue("listeGorseli")) { var cropUrl = yayin.GetCropUrl("listeGorseli", "liste"); <div class="entry-image"> <a href="@yayin.Url"><img src="@cropUrl" /></a> </div> } <div class="entry-title"> <h2><a href="@yayin.Url">@yayin.Name</a></h2> </div> <ul class="entry-meta clearfix"> <li><i class="icon-calendar3"></i> @yayin.CreateDate.ToString("dd MMMM yyyy")</li> </ul> <div class="entry-content"> <p>@yayin.GetPropertyValue("haberSpotYazi")</p> <a href="@yayin.Url" class="more-link">Daha Fazlas</a> </div> </div> }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Image Cropper from Media Picker in 7.7.1
Hi,
I'm trying to use image cropper from the new Media Picker. My Image Media Types are Image croppers. But I could not figure it out using dynamic content in an helper.
My code is as follows:
Thanks
Hi Bora
Do not use dynamics )) Best practice is to use strongly typed models in Umbraco.
Thanks,
Alex
Hi Bora
Please, show all your view code, we will find a problem together.
Thanks,
Alex
Hi Alex,
my whole code is like that:
Thanks for your help
Hi Bora
I would rewrite this code like that:
Hi Bora
Did you solve the issue?
Share with the community, please.
Thanks,
Alex
Thank you very much Alex. This solved it.
If you change your dynamic to IPublishedContent, you can then use this:
is working on a reply...