Merge branch 'netcore/netcore' into feature/8651-config-options-patten

# Conflicts:
#	src/Umbraco.Tests.Common/Builders/GlobalSettingsBuilder.cs
#	src/Umbraco.Tests/TEMP/DatabaseContextTests.sdf
#	src/Umbraco.Web.BackOffice/Controllers/ImagesController.cs
This commit is contained in:
Andy Butland
2020-08-27 09:03:01 +02:00
979 changed files with 9486 additions and 4278 deletions

View File

@@ -23,7 +23,10 @@ namespace Umbraco.Web.BackOffice.Controllers
private readonly ContentSettings _contentSettings;
private readonly IImageUrlGenerator _imageUrlGenerator;
public ImagesController(IMediaFileSystem mediaFileSystem, IOptions<ContentSettings> contentSettings, IImageUrlGenerator imageUrlGenerator)
public ImagesController(
IMediaFileSystem mediaFileSystem,
IOptions<ContentSettings> contentSettings,
IImageUrlGenerator imageUrlGenerator)
{
_mediaFileSystem = mediaFileSystem;
_contentSettings = contentSettings.Value;
@@ -67,7 +70,6 @@ namespace Umbraco.Web.BackOffice.Controllers
try
{
imageLastModified = _mediaFileSystem.GetLastModified(imagePath);
}
catch (Exception)
{
@@ -78,7 +80,14 @@ namespace Umbraco.Web.BackOffice.Controllers
}
var rnd = imageLastModified.HasValue ? $"&rnd={imageLastModified:yyyyMMddHHmmss}" : null;
var imageUrl = _imageUrlGenerator.GetImageUrl(new ImageUrlGenerationOptions(imagePath) { UpScale = false, Width = width, AnimationProcessMode = "first", ImageCropMode = ImageCropMode.Max, CacheBusterValue = rnd });
var imageUrl = _imageUrlGenerator.GetImageUrl(new ImageUrlGenerationOptions(imagePath)
{
UpScale = false,
Width = width,
AnimationProcessMode = "first",
ImageCropMode = ImageCropMode.Max,
CacheBusterValue = rnd
});
return new RedirectResult(imageUrl, false);
}
@@ -94,20 +103,30 @@ namespace Umbraco.Web.BackOffice.Controllers
/// <param name="animationProcessMode"></param>
/// <param name="mode"></param>
/// <param name="upscale"></param>
/// <param name="cacheBusterValue"></param>
/// <param name="crop"></param>
/// <param name="center"></param>
/// <returns></returns>
/// <remarks>
/// If there is no media, image property or image file is found then this will return not found.
/// </remarks>
public string GetProcessedImageUrl(string imagePath,
int? width = null,
int? height = null,
int? focalPointLeft = null,
int? focalPointTop = null,
string animationProcessMode = "first",
int? width = null,
int? height = null,
decimal? focalPointLeft = null,
decimal? focalPointTop = null,
string animationProcessMode = "first",
ImageCropMode mode = ImageCropMode.Max,
bool upscale = false,
string cacheBusterValue = "")
{
bool upscale = false,
string cacheBusterValue = "",
decimal? cropX1 = null,
decimal? cropX2 = null,
decimal? cropY1 = null,
decimal? cropY2 = null
)
{
var options = new ImageUrlGenerationOptions(imagePath)
{
AnimationProcessMode = animationProcessMode,
@@ -116,13 +135,35 @@ namespace Umbraco.Web.BackOffice.Controllers
ImageCropMode = mode,
UpScale = upscale,
Width = width,
Crop = (cropX1.HasValue && cropX2.HasValue && cropY1.HasValue && cropY2.HasValue) ? new ImageUrlGenerationOptions.CropCoordinates(cropX1.Value, cropY1.Value, cropX2.Value, cropY2.Value) : null,
FocalPoint = new ImageUrlGenerationOptions.FocalPointPosition(focalPointTop.GetValueOrDefault(0.5m), focalPointLeft.GetValueOrDefault(0.5m)),
};
if (focalPointLeft.HasValue && focalPointTop.HasValue)
{
options.FocalPoint = new ImageUrlGenerationOptions.FocalPointPosition(focalPointTop.Value, focalPointLeft.Value);
options.FocalPoint =
new ImageUrlGenerationOptions.FocalPointPosition(focalPointTop.Value, focalPointLeft.Value);
}
return _imageUrlGenerator.GetImageUrl(options);
}
public class FocalPointPositionModel
{
public decimal Left { get; set; }
public decimal Top { get; set; }
}
/// <summary>
/// The bounds of the crop within the original image, in whatever units the registered
/// IImageUrlGenerator uses, typically a percentage between 0 and 100.
/// </summary>
public class CropCoordinatesModel
{
public decimal X1 { get; set; }
public decimal Y1 { get; set; }
public decimal X2 { get; set;}
public decimal Y2 { get; set;}
}
}
}