Skip to content

Instantly share code, notes, and snippets.

View jesperordrup's full-sized avatar

Jesper Ordrup jesperordrup

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using umbraco.cms.businesslogic.Tags;
using Umbraco.Forms.Core;
using Umbraco.Web;
namespace Contour.Addon.Tags
{
<rules>
<rule name="SimpleCanonicalHostNameRule">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.example\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" />
</rule>
@Jeavon
Jeavon / gist:0bfa4c82a0dd43ff2c52
Created June 6, 2014 08:10
GetCropUrl - check for predefined and fall back if not
@{
if (feature.HasValue("Image"))
{
var featureImage = Umbraco.TypedMedia((int)feature.Image);
var myCropUrl = featureImage.GetCropUrl("PageBannerCrop") ?? featureImage.GetCropUrl(200, 100);
<a href="@feature.Url" class="image image-full"><img src="@myCropUrl" alt="" /></a>
}
}
public static string GetOptionalMediaUrl(this INode node, string propertyAlias)
{
int? mediaId = node.GetOptionalNullableValue<int>(propertyAlias);
if (mediaId.HasValue)
{
XPathNodeIterator media = library.GetMedia(mediaId.Value, false);
//we look at both //Image and //node, because some media items may not have been saved since the schema changed.
var file = media.Current.SelectSingleNode("//Image/umbracoFile | //node/data[@alias='umbracoFile']");
if (file != null)
return file.InnerXml;
@tylermenezes
tylermenezes / remove-rdio-garbage.js
Created December 9, 2012 10:01
Removes unavailable and preview albums from rdio. This is particularly useful after using the "Sync" feature, since it's useless and generates hundreds of "Unavailable" albums. Scroll to the bottom of your collection first, since it's lazy loaded.
(function(){
var i = 0;
var count = $('.Album.unavailable,.Album.preview').length;
console.log('Found ' + count + ' albums to remove');
var timeout = 0;
$('.Album.unavailable,.Album.preview').each(function(){
var instance_i = i++;
var album = $(this);
album.trigger('mouseover').mouseenter();
album.find('a,div,span,image').trigger('mouseover').mouseenter();