2
votes

I'm still new to Umbraco 7 but I've found my way around Surface Controllers.

I have created a SurfaceController which you can see future below. But what I can't figure out is how to grab the URL from an Image Cropper and File Upload, I would normally do something like this: @node.GetCropUrl("uploadImage, "thumbnail");

But that doesn't work inside the controller. How do I achieve this? My end goal is to display the URL in a IMG tag when clicking on a category on this page: http://sp34k.dk/portfolio/vue/ in the description area.

CODE:

https://jsfiddle.net/odg3zamx/7/
1
GetCropUrl is an extension method of IPublishedContent so just add using Umbraco.Web; inside your sufrace controller and you should be able to call GetCropUrl. - Davor Zlotrg
It worked like a charm buddy, thank you! If you'd like you can post a comment with your reply so I can flag it as the answer. If someone is curious then I added using Umbraco.Web; and gItem.imgUrl = node.GetCropUrl("uploadImage", "featured"); - user1049430

1 Answers

2
votes

GetCropUrl is an extension method of IPublishedContent so just add using Umbraco.Web; inside your sufrace controller and you should be able to call it. Like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Umbraco.Web.Mvc;
using Umbraco.Web;  //you are missing this namespace

public class PortfolioSurfaceController : SurfaceController
{
    // GET: PortfolioSurface
    public ActionResult GetCategoryDetails(int id)
    {
        GalleryItem gItem = new GalleryItem();
        var node = Umbraco.TypedContent(id);
        gItem.imgUrl = node.GetCropUrl("uploadImage", "featured");

        return Json(gItem, JsonRequestBehavior.AllowGet);
    }
}