Merge pull request #5178 from sbwalker/dev
add caching support for ImageUrl
This commit is contained in:
commit
f243ad0348
@ -23,6 +23,7 @@ using System.IO.Compression;
|
|||||||
using Oqtane.Services;
|
using Oqtane.Services;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
using Microsoft.AspNetCore.Http.HttpResults;
|
using Microsoft.AspNetCore.Http.HttpResults;
|
||||||
|
using Microsoft.Net.Http.Headers;
|
||||||
|
|
||||||
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
||||||
|
|
||||||
@ -735,6 +736,10 @@ namespace Oqtane.Controllers
|
|||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(imagepath))
|
if (!string.IsNullOrEmpty(imagepath))
|
||||||
{
|
{
|
||||||
|
if (!string.IsNullOrEmpty(file.Folder.CacheControl))
|
||||||
|
{
|
||||||
|
HttpContext.Response.Headers.Append(HeaderNames.CacheControl, value: file.Folder.CacheControl);
|
||||||
|
}
|
||||||
return PhysicalFile(imagepath, file.GetMimeType());
|
return PhysicalFile(imagepath, file.GetMimeType());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -121,6 +121,17 @@ namespace Oqtane.Shared
|
|||||||
return $"{alias?.BaseUrl}{url}{Constants.ImageUrl}{fileId}/{width}/{height}/{mode}/{position}/{background}/{rotate}/{recreate}";
|
return $"{alias?.BaseUrl}{url}{Constants.ImageUrl}{fileId}/{width}/{height}/{mode}/{position}/{background}/{rotate}/{recreate}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ImageUrl(Alias alias, string folderpath, string filename, int width, int height, string mode, string position, string background, int rotate, string format, bool recreate)
|
||||||
|
{
|
||||||
|
var aliasUrl = (alias != null && !string.IsNullOrEmpty(alias.Path)) ? "/" + alias.Path : "";
|
||||||
|
mode = string.IsNullOrEmpty(mode) ? "crop" : mode;
|
||||||
|
position = string.IsNullOrEmpty(position) ? "center" : position;
|
||||||
|
background = string.IsNullOrEmpty(background) ? "transparent" : background;
|
||||||
|
format = string.IsNullOrEmpty(format) ? "png" : format;
|
||||||
|
var querystring = $"?width={width}&height={height}&mode={mode}&position={position}&background={background}&rotate={rotate}&format={format}&recreate={recreate}";
|
||||||
|
return $"{alias?.BaseUrl}{aliasUrl}{Constants.FileUrl}{folderpath.Replace("\\", "/")}{filename}{querystring}";
|
||||||
|
}
|
||||||
|
|
||||||
public static string TenantUrl(Alias alias, string url)
|
public static string TenantUrl(Alias alias, string url)
|
||||||
{
|
{
|
||||||
url = (!url.StartsWith("/")) ? "/" + url : url;
|
url = (!url.StartsWith("/")) ? "/" + url : url;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user