Skip to content

Instantly share code, notes, and snippets.


Arnold Visser ArnoldV

  • Umbraco HQ
  • Netherlands
  • @aim24
View GitHub Profile
wjonesy / Base.cshtml
Last active Nov 5, 2018
A gist for using responsive images in Umbraco's grid editor
View Base.cshtml
@model dynamic
@using Umbraco.Web.Templates
@functions {
public static string EditorView(dynamic contentItem)
string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString();
view = view.ToLower().Replace(".html", ".cshtml");
if (!view.Contains("/"))
dampee / umbraco db cleanup.sql
Last active May 14, 2021
Umbraco Database cleanup. After pulling in an umbraco database from production, you don't need all history or log.
View umbraco db cleanup.sql
-- Umbraco Clear Old Document Versions To Decrease Database Size And Improve Performance
DECLARE @createdDate Datetime = DATEADD(m, -1, getdate())
-- dump logs
-- TRUNCATE TABLE umbracolog -- faster if log table is very big and you don't need anything
DELETE FROM umbracolog WHERE Datestamp < @createdDate
-- clean up old versions
rasmuseeg / Rte.cshtml
Created Aug 25, 2015
Parsing Macro's inside GridEditors
View Rte.cshtml
@using Umbraco.Web.Templates;
@using System.Text.RegularExpressions;
@using HtmlAgilityPack;
@model dynamic
<div class="cmscontent">
sniffdk / ContextHelpers.cs
Last active Jul 6, 2020
Fake an UmbracoContext for use when doing published scheduling or other scenarios where UmbracoContext is normally null.
View ContextHelpers.cs
public class ContextHelpers
public static UmbracoContext EnsureUmbracoContext() {
if (UmbracoContext.Current != null)
return UmbracoContext.Current;
var httpContext = new HttpContextWrapper(HttpContext.Current ?? new HttpContext(new SimpleWorkerRequest("temp.aspx", "", new StringWriter())));
barneycarroll /
Last active Feb 18, 2021
Lock and unlock a page's scroll position.


Useful for when a blocking user experience is needed (in my case, didn't want people unwittingly loosing their place by scrolling while a modal required their attention): $.scrollLock() locks the body in place, preventing scroll until it is unlocked.

// Locks the page if it's currently unlocked

// ...or vice versa