diff --git a/src/Umbraco.Web/Editors/ImagesController.cs b/src/Umbraco.Web.BackOffice/Controllers/ImagesController.cs similarity index 91% rename from src/Umbraco.Web/Editors/ImagesController.cs rename to src/Umbraco.Web.BackOffice/Controllers/ImagesController.cs index bbad627c3b..96eb120b25 100644 --- a/src/Umbraco.Web/Editors/ImagesController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ImagesController.cs @@ -2,10 +2,13 @@ using System.IO; using System.Net; using System.Net.Http; +using Microsoft.AspNetCore.Mvc; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.IO; using Umbraco.Core.Media; using Umbraco.Core.Models; +using Umbraco.Web.BackOffice.Controllers; +using Umbraco.Web.Common.Attributes; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi; @@ -36,10 +39,10 @@ namespace Umbraco.Web.Editors /// /// If there is no original image is found then this will return not found. /// - public HttpResponseMessage GetBigThumbnail(string originalImagePath) + public IActionResult GetBigThumbnail(string originalImagePath) { return string.IsNullOrWhiteSpace(originalImagePath) - ? Request.CreateResponse(HttpStatusCode.OK) + ? Ok() : GetResized(originalImagePath, 500); } @@ -52,22 +55,20 @@ namespace Umbraco.Web.Editors /// /// If there is no media, image property or image file is found then this will return not found. /// - public HttpResponseMessage GetResized(string imagePath, int width) + public IActionResult GetResized(string imagePath, int width) { var ext = Path.GetExtension(imagePath); // we need to check if it is an image by extension if (_contentSettings.IsImageFile(ext) == false) - return Request.CreateResponse(HttpStatusCode.NotFound); + return NotFound(); //redirect to ImageProcessor thumbnail with rnd generated from last modified time of original media file - var response = Request.CreateResponse(HttpStatusCode.Found); - DateTimeOffset? imageLastModified = null; try { imageLastModified = _mediaFileSystem.GetLastModified(imagePath); - + } catch (Exception) { @@ -80,8 +81,7 @@ namespace Umbraco.Web.Editors var rnd = imageLastModified.HasValue ? $"&rnd={imageLastModified:yyyyMMddHHmmss}" : null; var imageUrl = _imageUrlGenerator.GetImageUrl(new ImageUrlGenerationOptions(imagePath) { UpScale = false, Width = width, AnimationProcessMode = "first", ImageCropMode = "max", CacheBusterValue = rnd }); - response.Headers.Location = new Uri(imageUrl, UriKind.RelativeOrAbsolute); - return response; + return new RedirectResult(imageUrl, false); } /// diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs index edf50ba36b..33d4166112 100644 --- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs +++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs @@ -171,10 +171,11 @@ namespace Umbraco.Web.Editors "mediaApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( controller => controller.GetRootMedia()) }, - { - "imagesApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( - controller => controller.GetBigThumbnail("")) - }, + //TODO reintroduce + // { + // "imagesApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( + // controller => controller.GetBigThumbnail("")) + // }, { "sectionApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( controller => controller.GetSections()) diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 99a165e6fd..434d5eda88 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -346,7 +346,6 @@ -