Skip to content

Instantly share code, notes, and snippets.

@MineshS
MineshS / PromoBlock.cs
Created September 13, 2023 16:36
Promo Block
using System.ComponentModel.DataAnnotations;
using EPiServer.Core;
using EPiServer.DataAnnotations;
using Netcel.Optimizely.Domain.Groups;
using Netcel.Optimizely.Domain.Models.Blocks.Base;
using Netcel.Optimizely.Rendering.Attributes;
using Netcel.Optimizely.Rendering;
using EPiServer.Web;
using EPiServer.SpecializedProperties;
using Netcel.Optimizely.Domain.Attributes;
@MineshS
MineshS / ImageAttributes.cs
Created September 13, 2023 16:34
Image Property Attributes
namespace Netcel.Optimizely.Domain.Attributes;
[AttributeUsage(AttributeTargets.Property)]
public class ImageSizesAttribute : Attribute
{
public string Sizes { get; set; }
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class ImageSizeAttribute : Attribute
@MineshS
MineshS / PromoBlock.cshtml
Created September 13, 2023 16:32
PromoBlock Frontend Razor View
@using EPiServer.Core
@using Netcel.Optimizely.Core.Extensions.Helpers
@using Netcel.Optimizely.Core.TagHelpers
@model PromoBlock
<div class="promoBlockWrap">
@if (Model.PromoImage != null)
{
<div class="image" @Html.EditAttributes(x=>x.PromoImage)>
<img image-for="@Model.PromoImage" css-class="promoBlockImage" fit="cover" FlexibleAttribute="Goes Here"/>
@MineshS
MineshS / EdgeImageTagHelper.cs
Last active September 12, 2023 18:04
Edge Image Tag Helper
using System.Reflection;
using EPiServer.Core;
using EPiServer.Web.Routing;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.Hosting;
using Netcel.Optimizely.Core.Interfaces;
using Netcel.Optimizely.Domain.Attributes;
using Netcel.Optimizely.Domain.Models.Interfaces;