Adding Ratio Mode parameter to GetCropUrl helper
This commit is contained in:
@@ -127,13 +127,13 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Examine.0.1.55.2941\lib\Examine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ImageProcessor, Version=1.8.7.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="ImageProcessor, Version=1.8.8.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\ImageProcessor.1.8.7.0\lib\ImageProcessor.dll</HintPath>
|
||||
<HintPath>..\packages\ImageProcessor.1.8.8.0\lib\ImageProcessor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ImageProcessor.Web, Version=3.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="ImageProcessor.Web, Version=3.2.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\ImageProcessor.Web.3.2.1.0\lib\net45\ImageProcessor.Web.dll</HintPath>
|
||||
<HintPath>..\packages\ImageProcessor.Web.3.2.2.0\lib\net45\ImageProcessor.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=1.2.11.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
||||
@@ -93,6 +93,9 @@ namespace Umbraco.Web
|
||||
/// <param name="furtherOptions">
|
||||
/// The further options.
|
||||
/// </param>
|
||||
/// <param name="ratioMode">
|
||||
/// Use a dimension as a ratio
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="string"/>.
|
||||
/// </returns>
|
||||
@@ -108,7 +111,9 @@ namespace Umbraco.Web
|
||||
bool preferFocalPoint = false,
|
||||
bool useCropDimensions = false,
|
||||
bool cacheBuster = true,
|
||||
string furtherOptions = null)
|
||||
string furtherOptions = null,
|
||||
ImageCropRatioMode? ratioMode = null
|
||||
)
|
||||
{
|
||||
string imageCropperValue = null;
|
||||
|
||||
@@ -133,7 +138,7 @@ namespace Umbraco.Web
|
||||
var cacheBusterValue = cacheBuster ? mediaItem.UpdateDate.ToFileTimeUtc().ToString(CultureInfo.InvariantCulture) : null;
|
||||
|
||||
return mediaItemUrl != null
|
||||
? GetCropUrl(mediaItemUrl, width, height, imageCropperValue, cropAlias, quality, imageCropMode, imageCropAnchor, preferFocalPoint, useCropDimensions, cacheBusterValue, furtherOptions)
|
||||
? GetCropUrl(mediaItemUrl, width, height, imageCropperValue, cropAlias, quality, imageCropMode, imageCropAnchor, preferFocalPoint, useCropDimensions, cacheBusterValue, furtherOptions, ratioMode)
|
||||
: string.Empty;
|
||||
}
|
||||
|
||||
@@ -176,6 +181,9 @@ namespace Umbraco.Web
|
||||
/// <param name="furtherOptions">
|
||||
/// The further options.
|
||||
/// </param>
|
||||
/// <param name="ratioMode">
|
||||
/// Use a dimension as a ratio
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The <see cref="string"/>.
|
||||
/// </returns>
|
||||
@@ -191,7 +199,9 @@ namespace Umbraco.Web
|
||||
bool preferFocalPoint = false,
|
||||
bool useCropDimensions = false,
|
||||
string cacheBusterValue = null,
|
||||
string furtherOptions = null)
|
||||
string furtherOptions = null,
|
||||
ImageCropRatioMode? ratioMode = null
|
||||
)
|
||||
{
|
||||
if (string.IsNullOrEmpty(imageUrl) == false)
|
||||
{
|
||||
@@ -235,16 +245,28 @@ namespace Umbraco.Web
|
||||
imageResizerUrl.Append("&quality=" + quality);
|
||||
}
|
||||
|
||||
if (width != null && useCropDimensions == false)
|
||||
if (width != null && useCropDimensions == false && ratioMode != ImageCropRatioMode.Width)
|
||||
{
|
||||
imageResizerUrl.Append("&width=" + width);
|
||||
}
|
||||
|
||||
if (height != null && useCropDimensions == false)
|
||||
if (height != null && useCropDimensions == false && ratioMode != ImageCropRatioMode.Height)
|
||||
{
|
||||
imageResizerUrl.Append("&height=" + height);
|
||||
}
|
||||
|
||||
if (ratioMode == ImageCropRatioMode.Width)
|
||||
{
|
||||
var widthRatio = (decimal)width/(decimal)height;
|
||||
imageResizerUrl.Append("&widthratio=" + widthRatio.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
if (ratioMode == ImageCropRatioMode.Height)
|
||||
{
|
||||
var heightRatio = (decimal)height/(decimal)width;
|
||||
imageResizerUrl.Append("&heightratio=" + heightRatio.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
if (furtherOptions != null)
|
||||
{
|
||||
imageResizerUrl.Append(furtherOptions);
|
||||
|
||||
8
src/Umbraco.Web/Models/ImageCropRatioMode.cs
Normal file
8
src/Umbraco.Web/Models/ImageCropRatioMode.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Umbraco.Web.Models
|
||||
{
|
||||
public enum ImageCropRatioMode
|
||||
{
|
||||
Width,
|
||||
Height
|
||||
}
|
||||
}
|
||||
@@ -350,6 +350,7 @@
|
||||
<Compile Include="Models\ContentEditing\ListViewAwareContentItemDisplayBase.cs" />
|
||||
<Compile Include="Models\ContentEditing\PropertyTypeValidation.cs" />
|
||||
<Compile Include="Models\ImageCropData.cs" />
|
||||
<Compile Include="Models\ImageCropRatioMode.cs" />
|
||||
<Compile Include="Models\IRenderModel.cs" />
|
||||
<Compile Include="Models\PostRedirectModel.cs" />
|
||||
<Compile Include="Models\PublishedProperty.cs" />
|
||||
|
||||
Reference in New Issue
Block a user