Orchardcore media slugify

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore media slugify is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for enabling SEO-friendly slugified media folder and file names in Orchard Core. Covers the OrchardCore.Media.Slugify feature, the OrchardCore Media Slugify configuration section and its Transliterate option, environment variable names, name normalization behavior, collisions, and custom IMedi

How to use this skill

Skill file

Orchard Core Media Slugify

Slugify Media Names

Enable the Media Slugify feature so newly created media folders and files get

SEO-friendly, URL-safe names.

Guidelines

Enabling Media Slugify

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "OrchardCore.Media.Slugify"
      ],
      "disable": []
    }
  ]
}

Configuration (`OrchardCore:Media:Slugify`)

{
  "OrchardCore": {
    "Media": {
      "Slugify": {
        "Transliterate": true
      }
    }
  }
}

Custom Normalizer

Replace the normalizer to apply your own naming rules (it is scoped):

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using OrchardCore.Media;
using OrchardCore.Modules;

public sealed class LowercaseMediaNameNormalizer : IMediaNameNormalizerService
{
    public string NormalizeFolderName(string folderName)
        => folderName.Trim().ToLowerInvariant();

    public string NormalizeFileName(string fileName)
        => Path.GetFileNameWithoutExtension(fileName).Trim().ToLowerInvariant() + Path.GetExtension(fileName).ToLowerInvariant();
}

[RequireFeatures("OrchardCore.Media")]
public sealed class Startup : StartupBase
{
    // Run after the Media and Media Slugify startups so this registration wins.
    public override int Order => 10;

    public override void ConfigureServices(IServiceCollection services)
    {
        services.Replace(ServiceDescriptor.Scoped<IMediaNameNormalizerService, LowercaseMediaNameNormalizer>());
    }
}

Notes

Upgrading from 3.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.