All skills
michtio avatar

/craft-plugins

@44a2800

Index and router for plugin-specific Craft CMS 5 guidance — configuration, Twig API, PHP API, migrations, deployment, and pitfalls for the plugins this pack documents. Triggers whenever a task names one of these plugins in ANY context (build, configure, style, render, query, import, migrate, deploy, cache, debug): Formie (forms, submissions, File Upload, form in a migration, notifications, translations), SEOmatic (meta, sitemaps, JSON-LD, SEO field), Blitz (static/page caching, purge), Feed Me (XML/JSON/CSV import), Imager-X (transforms, srcset, quick syntax, named transforms, Power Pack, pppicture, ppimg), ImageOptimize (OptimizedImages), CKEditor (rich text, nested entries), Sprig (reactive, htmx), Element API (JSON endpoints), Retour (redirects, 404s), Navigation (nav menus), Hyper (link field), Colour Swatches, Password Policy (HIBP), Typogrify, Cache Igniter, Knock Knock (staging password), Elements Panel (N+1 debug), Sherlock (security scan), Amazon SES (SES/SNS bounce), Embedded Assets (oEmbed), Timeloop (recurring dates), Vite (craft.vite.*, asset bundling), Warp (passwordless login, magic link, one-time code/OTP, passkeys, WebAuthn, craft.warp, member sessions). Also load for passwordless or magic-link auth with NO plugin named. Always load when a task names one of these plugins — read references/<plugin>.md first. Do NOT trigger for Craft core with no plugin named (craftcms), template architecture (craft-site), or content modeling (craft-content-modeling).

Use this Skill: https://skilld.dev/gh/michtio/craftcms-claude-skills/craft-plugins

This session only. Nothing lands on disk.

referencesimage-optimize.md

≈1.7k tokens on demand. Your agent reads this file only when SKILL.md points to it.

ImageOptimize

Automatic responsive image transform generation by nystudio107. Adds an OptimizedImages field type that pre-generates responsive variants and provides Twig helpers for <img> and <picture> output. Supports native Craft transforms, imgix, Thumbor, Sharp JS, and Cloudinary as transform backends.

nystudio107/craft-imageoptimize — $59

Documentation

When unsure about an ImageOptimize feature, WebFetch the relevant docs page.

Common Pitfalls

  • Adding the OptimizedImages field to a Section field layout instead of the Asset Volume field layout — the field must be on the Asset Volume, not the Section. It generates variants for the asset itself.
  • Forgetting to call .render() on tag builders — .imgTag() and .pictureTag() return builder objects, not HTML strings. Chain .render() at the end.
  • Not running ddev craft image-optimize/optimize/create after adding new variants — existing assets don't auto-regenerate unless you resave them or run the console command.
  • Using ImageOptimize on Craft Cloud — Craft Cloud handles transforms via Cloudflare Images at the edge. ImageOptimize is for self-hosted or imgix/Thumbor setups. Don't use both. See the craft-cloud skill's assets-and-transforms.md for Cloud's transform limits and limitations.md for the broader plugin-compatibility map.
  • Missing --force flag when adding WebP variants after the fact — existing transforms won't be recreated unless forced.
  • Expecting real-time transform generation — transforms are pre-generated as queue jobs on asset save, not at request time. Large uploads may take a moment.

Setup

  1. Install the plugin
  2. Configure the transform method in Settings (Craft, imgix, Thumbor, or Sharp JS)
  3. Create an OptimizedImages field (one per srcset you need)
  4. Add the field to the Asset Volume field layout
  5. Define image variants (widths, aspect ratios, formats)
  6. Resave assets: ddev craft image-optimize/optimize/create

Twig API — Tag Builders

imgTag() (Recommended)

{% set asset = entry.heroImage.one() %}
{% if asset %}
    {{ asset.optimizedImagesField.imgTag()
        .loadingStrategy('lazy')
        .render() }}
{% endif %}

Generates a complete <img> tag with srcset, sizes, width, height, loading, and decoding attributes.

pictureTag()

{% set asset = entry.heroImage.one() %}
{% if asset %}
    {{ asset.optimizedImagesField.pictureTag()
        .loadingStrategy('lazy')
        .render() }}
{% endif %}

Generates <picture> with <source> elements for WebP/AVIF and fallback <img>.

Chained Configuration

Both tag builders support chaining:

{{ asset.optimizedImagesField.imgTag()
    .loadingStrategy('lazy')
    .sizes('(max-width: 768px) 100vw, 50vw')
    .render() }}

{{ asset.optimizedImagesField.imgTag()
    .loadingStrategy('eager')
    .render() }}

Object Configuration

{{ asset.optimizedImagesField.imgTag({
    'loadingStrategy': 'lazy',
    'sizes': '100vw',
}).render() }}

Loading Strategies

Strategy Output Use for
'lazy' loading="lazy" decoding="async" Below-the-fold images
'eager' fetchpriority="high" Hero/LCP images
'lazySizes' LazySizes.js integration Legacy browser support

Twig API — Direct Access

Source URLs and Srcsets

{% set optimized = asset.optimizedImagesField %}

{# Single best-fit URL #}
{{ optimized.src }}

{# Full srcset string #}
{{ optimized.srcset }}

{# WebP srcset #}
{{ optimized.srcsetWebp }}

{# Srcset filtered by width #}
{{ optimized.srcsetMinWidth(600) }}
{{ optimized.srcsetMaxWidth(1200) }}

{# Max available width (prevent upscaling) #}
{{ optimized.maxSrcsetWidth }}

Placeholders (Lazy Loading)

{# Low-quality image placeholder (base64 inline) #}
{{ optimized.placeholderImage }}

{# SVG silhouette placeholder #}
{{ optimized.placeholderSilhouette }}

{# Solid color box placeholder #}
{{ optimized.placeholderBox }}

{# Arbitrary placeholder box #}
{{ craft.imageOptimize.placeholderBox(100, 100, '#CCC') }}

Color Palette

{# Extracted dominant colors from the image #}
{% for color in optimized.colorPalette %}
    <div style="background-color: {{ color }}"></div>
{% endfor %}

Dimensions

{{ optimized.originalImageWidth }}
{{ optimized.originalImageHeight }}
{{ optimized.placeholderWidth }}
{{ optimized.placeholderHeight }}

Console Commands

# Create all optimized image variants
ddev craft image-optimize/optimize/create

# Create variants for a specific field only
ddev craft image-optimize/optimize/create --field=heroImage

# Force recreation (required when adding new formats like WebP)
ddev craft image-optimize/optimize/create --force

# Clear all generated variants
ddev craft image-optimize/optimize/clear

Config File

// config/image-optimize.php
return [
    '*' => [
        // Automatically resave image variants when field/volume settings change
        'automaticallyResaveImageVariants' => true,

        // Generate placeholders and color palettes
        'createColorPalette' => true,
        'createPlaceholderSilhouettes' => true,

        // Sharpening threshold (% size reduction before auto-sharpening applies)
        'autoSharpenScaledImages' => true,
        'sharpenScaledImagePercentage' => 50,

        // Lower quality for smaller file sizes (0-100)
        'lowerQualityRetinaImageVariants' => true,
    ],
];

Transform Methods

Method Package Description
Craft Built-in Native Craft transforms (GD/Imagick)
imgix Built-in imgix URL-based transforms
Thumbor Built-in Open-source image service
Sharp JS Built-in AWS Lambda serverless transforms

Configure in CP → Settings → ImageOptimize → Transform Method.

GraphQL

{
  entries(section: "news") {
    ... on news_article_Entry {
      heroImage {
        optimizedImagesField {
          src
          srcset
          srcsetWebp
          placeholderImage
          originalImageWidth
          originalImageHeight
        }
      }
    }
  }
}

Pair With

  • Imager-X — alternative transform engine with more CDN backend options
  • Small Pics — URL-based image service (Imager-X transformer or standalone)

Source: SKILL.md on GitHub

No alerts16d3 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The 'craft-plugins' skill is a technical reference and router for Craft CMS 5 plugins. It provides guidance on configuration, Twig and PHP APIs, and best practices for popular extensions in the Craft ecosystem. The skill consists of documentation files that describe legitimate plugin behaviors and does not contain any malicious code, obfuscation, or security vulnerabilities.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

Signed by skilld at 44a2800. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated last month

README badge

README badge for michtio/craftcms-claude-skills/craft-plugins