So I 'think' - that the issue here might be how you are passing in the IPublishedContent item into the helper - because you are using V7, Umbraco.Content() doesn't return an IPublishedContent item it returns
a dynamic object - if you use Umbraco.TypedContent() you should get the object back as an IPublishedContent item:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Umbraco.Web
@{
//because you are inheriting from UmbracoTemplatePage you already have access to the UmbracoHelper via @Umbraco
// var UmbHelper = new UmbracoHelper(UmbracoContext.Current);
//think this is just whilst you are testing? - Model.Content.Id should give you the current page id
var thisPageId = 12855;
var stringPage = @ViewData["pageId"];
thisPageId = Convert.ToInt32(stringPage);
var pageinfo = Umbraco.TypedContent(thisPageId);
//pageInfo is now an IPublishedContent item representing the page iwth Id 12855 - if this is the 'current' page you could access this via Model.Content
// now get the IPublishedContent item representing the Media Item (this uses PropertyValueConverters to convert the picked image into IPublishedContent
var mediaItem = pageInfo.HasValue("image") ? pageInfo.GetPropertyValue<IPublishedContent>("image") : default(IPublishedContent);
//if you don't have PropertyValueConverters enabled < v7.6 then
// var mediaItem = pageInfo.HasValue("image") ? Umbraco.TypedMedia(pageInfo.GetPropertyValue("image")) : default(IPublishedContent);
if (mediaItem!=null){
var cropUrl = Url.GetCropUrl(mediaItem, "pagecontent_stz", false);
}
}
Anyway hopefully that gives the gist of what it might not be working!
Define Image cropper in partial view
Hello everyone,
I would like to implement the image cropper, however I get stuck in the definition area. This is my code:
This gives me this error: CS1973: 'UrlHelper' has no applicable method named 'GetCropUrl' but appears to have an extension method by that name.
Does anyone have an idea?
Thanks a lot! Simeon
Hi Simeon
The extensions method you are looking to use has the signature:
So I 'think' - that the issue here might be how you are passing in the IPublishedContent item into the helper - because you are using V7, Umbraco.Content() doesn't return an
IPublishedContent
item it returns adynamic
object - if you use Umbraco.TypedContent() you should get the object back as anIPublishedContent
item:}
Anyway hopefully that gives the gist of what it might not be working!
regards
Marc
Hi Marc,
Thank you for your reply! When using this code
I get, that there is a "}" missing, what I don't understand.
Thanks! Simeon
Hi everyone,
I would be happy to get any idea...
Thanks a million!
Best, Simeon
Hi everyone,
I finally found the solution with the help of this thread: https://our.umbraco.com/forum/templates-partial-views-and-macros/87310-763-image-cropper-again
This is the code, which finally worked:
Best, Simeon
is working on a reply...