Skip to content

Commit

Permalink
Merge pull request #44 from AndyBoot/updates/our-img
Browse files Browse the repository at this point in the history
<our-img> TagHelper
  • Loading branch information
Warren Buckley authored Nov 17, 2022
2 parents 1f0ce8b + 9170a6c commit fe1dbaa
Show file tree
Hide file tree
Showing 6 changed files with 687 additions and 1 deletion.
25 changes: 25 additions & 0 deletions Our.Umbraco.TagHelpers/Classes/OurImageSize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Our.Umbraco.TagHelpers.Enums;

namespace Our.Umbraco.TagHelpers.Classes
{
internal class OurImageSize
{
public OurImageSize() { }
public OurImageSize(OurScreenSize screenSize, int imageWidth, string? cropAlias = null)
{
ScreenSize = screenSize;
ImageWidth = imageWidth;
CropAlias = cropAlias;
}
public OurImageSize(OurScreenSize screenSize, int imageWidth, int imageHeight)
{
ScreenSize = screenSize;
ImageWidth = imageWidth;
ImageHeight = imageHeight;
}
public OurScreenSize ScreenSize { get; set; }
public int ImageWidth { get; set; }
public int ImageHeight { get; set; }
public string? CropAlias { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
namespace Our.Umbraco.TagHelpers.Configuration
using Our.Umbraco.TagHelpers.Enums;

namespace Our.Umbraco.TagHelpers.Configuration
{
public class OurUmbracoTagHelpersConfiguration
{
public InlineSvgTagHelperConfiguration OurSVG { get; set; } = new InlineSvgTagHelperConfiguration();
public ImgTagHelperConfiguration OurImg { get; set; } = new ImgTagHelperConfiguration();
}

public class InlineSvgTagHelperConfiguration
Expand All @@ -11,4 +14,47 @@ public class InlineSvgTagHelperConfiguration
public bool Cache { get; set; } = false;
public int CacheMinutes { get; set; } = 180;
}

public class ImgTagHelperConfiguration
{
/// <summary>
/// Define the typical responsive breakpoints (S,M,L,XL,XXL) in which your website uses during screen resize
/// </summary>
public MediaQuerySizes MediaQueries { get; set; } = new MediaQuerySizes();

/// <summary>
/// If true, let the browser handle image lazy loading, otherwise disable to use a 3rd party JavaScript based library
/// </summary>
public bool UseNativeLazyLoading { get; set; } = true;

/// <summary>
/// Applicable if UseNativeLazyLoading is false
/// </summary>
public string LazyLoadCssClass { get; set; } = "lazyload";

/// <summary>
/// Applicable if UseNativeLazyLoading is false
/// </summary>
public ImagePlaceholderType LazyLoadPlaceholder { get; set; } = ImagePlaceholderType.SVG;

/// <summary>
/// Applicable if UseNativeLazyLoading is false & LazyLoadPlaceholder is LowQualityImage
/// </summary>
public int LazyLoadPlaceholderLowQualityImageQuality { get; set; } = 5;
public bool ApplyAspectRatio { get; set; } = false;
public bool MobileFirst { get; set; } = true;

/// <summary>
/// The property alias of the media type containing the alternative text value.
/// </summary>
public string AlternativeTextMediaTypePropertyAlias { get; set; } = "alternativeText";
}
public class MediaQuerySizes
{
public int Small { get; set; } = 576;
public int Medium { get; set; } = 768;
public int Large { get; set; } = 992;
public int ExtraLarge { get; set; } = 1200;
public int ExtraExtraLarge { get; set; } = 1400;
}
}
14 changes: 14 additions & 0 deletions Our.Umbraco.TagHelpers/Enums/ImagePlaceholderType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Our.Umbraco.TagHelpers.Enums
{
public enum ImagePlaceholderType
{
SVG,
LowQualityImage
}
}
17 changes: 17 additions & 0 deletions Our.Umbraco.TagHelpers/Enums/OurScreenSize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Our.Umbraco.TagHelpers.Enums
{
public enum OurScreenSize
{
Small = 100,
Medium = 200,
Large = 300,
ExtraLarge = 400,
ExtraExtraLarge = 500
}
}
Loading

0 comments on commit fe1dbaa

Please sign in to comment.