Skip to content

Commit fe1dbaa

Browse files
author
Warren Buckley
authored
Merge pull request #44 from AndyBoot/updates/our-img
<our-img> TagHelper
2 parents 1f0ce8b + 9170a6c commit fe1dbaa

File tree

6 files changed

+687
-1
lines changed

6 files changed

+687
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Our.Umbraco.TagHelpers.Enums;
2+
3+
namespace Our.Umbraco.TagHelpers.Classes
4+
{
5+
internal class OurImageSize
6+
{
7+
public OurImageSize() { }
8+
public OurImageSize(OurScreenSize screenSize, int imageWidth, string? cropAlias = null)
9+
{
10+
ScreenSize = screenSize;
11+
ImageWidth = imageWidth;
12+
CropAlias = cropAlias;
13+
}
14+
public OurImageSize(OurScreenSize screenSize, int imageWidth, int imageHeight)
15+
{
16+
ScreenSize = screenSize;
17+
ImageWidth = imageWidth;
18+
ImageHeight = imageHeight;
19+
}
20+
public OurScreenSize ScreenSize { get; set; }
21+
public int ImageWidth { get; set; }
22+
public int ImageHeight { get; set; }
23+
public string? CropAlias { get; set; }
24+
}
25+
}
Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
namespace Our.Umbraco.TagHelpers.Configuration
1+
using Our.Umbraco.TagHelpers.Enums;
2+
3+
namespace Our.Umbraco.TagHelpers.Configuration
24
{
35
public class OurUmbracoTagHelpersConfiguration
46
{
57
public InlineSvgTagHelperConfiguration OurSVG { get; set; } = new InlineSvgTagHelperConfiguration();
8+
public ImgTagHelperConfiguration OurImg { get; set; } = new ImgTagHelperConfiguration();
69
}
710

811
public class InlineSvgTagHelperConfiguration
@@ -11,4 +14,47 @@ public class InlineSvgTagHelperConfiguration
1114
public bool Cache { get; set; } = false;
1215
public int CacheMinutes { get; set; } = 180;
1316
}
17+
18+
public class ImgTagHelperConfiguration
19+
{
20+
/// <summary>
21+
/// Define the typical responsive breakpoints (S,M,L,XL,XXL) in which your website uses during screen resize
22+
/// </summary>
23+
public MediaQuerySizes MediaQueries { get; set; } = new MediaQuerySizes();
24+
25+
/// <summary>
26+
/// If true, let the browser handle image lazy loading, otherwise disable to use a 3rd party JavaScript based library
27+
/// </summary>
28+
public bool UseNativeLazyLoading { get; set; } = true;
29+
30+
/// <summary>
31+
/// Applicable if UseNativeLazyLoading is false
32+
/// </summary>
33+
public string LazyLoadCssClass { get; set; } = "lazyload";
34+
35+
/// <summary>
36+
/// Applicable if UseNativeLazyLoading is false
37+
/// </summary>
38+
public ImagePlaceholderType LazyLoadPlaceholder { get; set; } = ImagePlaceholderType.SVG;
39+
40+
/// <summary>
41+
/// Applicable if UseNativeLazyLoading is false & LazyLoadPlaceholder is LowQualityImage
42+
/// </summary>
43+
public int LazyLoadPlaceholderLowQualityImageQuality { get; set; } = 5;
44+
public bool ApplyAspectRatio { get; set; } = false;
45+
public bool MobileFirst { get; set; } = true;
46+
47+
/// <summary>
48+
/// The property alias of the media type containing the alternative text value.
49+
/// </summary>
50+
public string AlternativeTextMediaTypePropertyAlias { get; set; } = "alternativeText";
51+
}
52+
public class MediaQuerySizes
53+
{
54+
public int Small { get; set; } = 576;
55+
public int Medium { get; set; } = 768;
56+
public int Large { get; set; } = 992;
57+
public int ExtraLarge { get; set; } = 1200;
58+
public int ExtraExtraLarge { get; set; } = 1400;
59+
}
1460
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Our.Umbraco.TagHelpers.Enums
8+
{
9+
public enum ImagePlaceholderType
10+
{
11+
SVG,
12+
LowQualityImage
13+
}
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Our.Umbraco.TagHelpers.Enums
8+
{
9+
public enum OurScreenSize
10+
{
11+
Small = 100,
12+
Medium = 200,
13+
Large = 300,
14+
ExtraLarge = 400,
15+
ExtraExtraLarge = 500
16+
}
17+
}

0 commit comments

Comments
 (0)