AgentSkillsCN

webp-images

将图片嵌入页面部分。从 /public/raw/[page]/ 转换为 WebP 并提供响应式变体,用 Next.js Image 组件替换 CDN 占位符。在 midjourney-prompts 技能之后使用。触发条件包括“嵌入图片”、“向页面添加图片”、“替换占位符图片”。

SKILL.md
--- frontmatter
name: webp-images
description: Implement images into page sections. Converts from /public/raw/[page]/ to WebP with responsive variants, replaces CDN placeholders with Next.js Image component. Use after midjourney-prompts skill. Triggers on "implement images", "add images to page", "replace placeholder images".

Image Implementation

Convert and implement images into page sections.

Workflow

  1. User provides: page route, source folder, image-to-section mapping
  2. Run WebP conversion script
  3. Replace CDN placeholders with Next.js <Image>
  4. Add alt text keys to i18n files

Convert Images

bash
./scripts/convert-to-webp.sh [input_dir] [output_dir]

Default paths:

  • Input: /public/raw/[page]/
  • Output: /public/images/[page]/

Generates responsive variants: 640w, 1024w, 1920w

Replace Patterns

See references/nextjs-patterns.md for code examples.

Quick Reference

Image TypePropsUse Case
Fixed sizewidth, heightTestimonials, logos
Fill containerfill, sizesHero, project thumbnails
Above foldpriorityFirst visible image
Object fitclassName="object-cover"Cropped images

i18n Alt Text

Add to messages/de.json and messages/en.json:

json
{
  "hero": {
    "imageAlt": "Beschreibung des Bildes"
  },
  "projects": {
    "items": {
      "0": { "imageAlt": "Projekt 1 Beschreibung" }
    }
  }
}

Checklist

  • Images converted to WebP
  • Responsive variants generated
  • CDN URLs replaced with local paths
  • <img> tags converted to <Image>
  • Alt text added to i18n
  • priority set for above-fold images
  • sizes prop set for responsive images