【问题标题】:Umbraco: Get ImageCropper & File Upload via SurfaceControllerUmbraco:通过 SurfaceController 获取 ImageCropper 和文件上传
【发布时间】:2016-07-07 07:26:22
【问题描述】:

我还是 Umbraco 7 的新手,但我已经找到了 Surface Controllers 的方法。

我创建了一个 SurfaceController,您可以在下面看到它的未来。但我不知道如何从图像裁剪器和文件上传中获取 URL,我通常会这样做:@node.GetCropUrl("uploadImage, "thumbnail");

但这在控制器内部不起作用。我如何实现这一目标?我的最终目标是在单击此页面上的类别时在 IMG 标记中显示 URL:描述区域中的http://sp34k.dk/portfolio/vue/

代码:

https://jsfiddle.net/odg3zamx/7/

【问题讨论】:

  • GetCropUrlIPublishedContent 的扩展方法,所以只需在您的表面控制器中添加using Umbraco.Web;,您应该可以调用GetCropUrl。
  • 它就像一个魅力伙伴,谢谢!如果您愿意,可以在回复中发表评论,以便我将其标记为答案。如果有人好奇,那么我使用 Umbraco.Web 添加;和 gItem.imgUrl = node.GetCropUrl("uploadImage", "featured");

标签: umbraco umbraco7


【解决方案1】:

GetCropUrlIPublishedContent 的扩展方法,所以只需在你的表面控制器中添加using Umbraco.Web; 就可以调用它了。像这样:

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);
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-27
    • 2011-08-20
    • 1970-01-01
    • 2010-12-20
    相关资源
    最近更新 更多