-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
umbFeatures.cshtml
145 lines (125 loc) · 6.27 KB
/
umbFeatures.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
@using Umbraco.Web.Models
@inherits UmbracoTemplatePage
@{
// Model.Content is the current page that we're on
// AncestorsOrSelf is all of the ancestors this page has in the tree
// (1) means: go up to level 1 and stop looking for more ancestors when you get there
// First() gets the first ancestor found (the home page, on level 1)
var homePage = CurrentPage.AncestorsOrSelf(1).First();
}
@{
var featuredPages = Model.Content.AncestorOrSelf(1).Children("umbTextPage").Where(x => x.GetPropertyValue<bool>("featuredPage"));
}
<!-- Features -->
<section class="is-features">
<h2 class="major"><span>Wonderful featured pages</span></h2>
<div>
<div class="row">
<h2>Using Image Source Set using Pre Defined Crop</h2>
@foreach (var feature in featuredPages)
{
<div class="3u">
<section class="is-feature">
@if (feature.HasValue("image"))
{
var featureImage = Umbraco.TypedMedia(feature.GetPropertyValue<int>("image"));
<a href="@feature.Url" class="image image-full">
<img data-srcset="@Url.GetSrcSetUrls(featureImage, "home", "umbracoFile")" data-src="@Url.GetCropUrl(featureImage, "umbracoFile", "home")" data-sizes="auto" class="lazyload"/>
</a>
}
<h3><a href="@feature.Url">@feature.Name</a>
</h3>
@Umbraco.Truncate(feature.GetPropertyValue<string>("bodyText"), 100)
</section>
</div>
}
</div>
<div class="row">
<h2>Using Image Source Set with picture element and WebP ImageProcessor Plugin</h2>
@foreach (var feature in featuredPages)
{
var featureImage = Umbraco.TypedMedia(feature.GetPropertyValue<int>("image"));
<div class="3u">
<!-- Feature -->
<section class="is-feature">
<picture>
<!--[if IE 9]><video style="display: none"><![endif]-->
<source data-srcset="@Url.GetSrcSetUrls(featureImage, 270, 161, "umbracoFile", "webp", quality:80)" type="image/webp" data-sizes="auto"/>
<source data-srcset="@Url.GetSrcSetUrls(featureImage, 270, 161)" type="image/jpeg" data-sizes="auto"/>
<!--[if IE 9]></video><![endif]-->
<img
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="@Url.GetCropUrl(featureImage, 270, 161)"
class="lazyload"
alt="image with artdirection"
data-sizes="auto"/>
</picture>
</section>
</div>
}
</div>
<div class="row">
<h2>Using Image Source Set with picture element, WebP ImageProcessor Plugin and LQIP using Razor Helper</h2>
@foreach (var feature in featuredPages)
{
var featureImage = Umbraco.TypedMedia(feature.GetPropertyValue<int>("image"));
<div class="3u">
<!-- Feature -->
<section class="is-feature">
@SlimsyHelper.RenderPicture(Url, featureImage, 270, 161)
</section>
</div>
}
</div>
<div class="row">
<h2>Using Image Source Set with Aspect Ratio</h2>
@foreach (var feature in featuredPages)
{
var ratio = new AspectRatio(16, 9);
<div class="3u">
<section class="is-feature">
@if (feature.HasValue("image"))
{
var featureImage = Umbraco.TypedMedia(feature.GetPropertyValue<int>("image"));
<a href="@feature.Url" class="image image-full">
<img data-srcset="@Url.GetSrcSetUrls(featureImage, ratio)" data-src="@Url.GetCropUrl(featureImage, 270, 161)" data-sizes="auto" class="lazyload" />
</a>
}
<h3>
<a href="@feature.Url">@feature.Name</a>
</h3>
@Umbraco.Truncate(feature.GetPropertyValue<string>("bodyText"), 100)
</section>
</div>
}
</div>
<div class="row">
<h2>Using Image Source Set with LQIP</h2>
@foreach (var feature in featuredPages)
{
var featureImage = Umbraco.TypedMedia(feature.GetPropertyValue<int>("image"));
<div class="3u">
<!-- Feature -->
<section class="is-feature">
<img src="@Url.GetCropUrl(featureImage, 270, 161, quality:30, furtherOptions:"&format=auto")" data-srcset="@Url.GetSrcSetUrls(featureImage, 270, 161)" data-src="@Url.GetCropUrl(featureImage, 270, 161)" data-sizes="auto" class="lazyload" alt="something really long"/>
</section>
</div>
}
</div>
<div class="row">
<h2>Using Image Source Set with LQIP and flexible heights</h2>
@foreach (var feature in featuredPages)
{
var featureImage = Umbraco.TypedMedia(feature.GetPropertyValue<int>("image"));
<div class="3u">
<!-- Feature -->
<section class="is-feature">
<img src="@Url.GetCropUrl(featureImage, 270, 0, quality:30, furtherOptions:"&format=auto")" data-srcset="@Url.GetSrcSetUrls(featureImage, 270, 0)" data-src="@Url.GetCropUrl(featureImage, 270, 0)" data-sizes="auto" class="lazyload" alt="something really long"/>
</section>
</div>
}
</div>
</div>
</section>
@Html.Partial("/Views/Partials/_Slider.cshtml", featuredPages)
<!-- /Features -->