定制 moritz-sauer-13/silverstripe-ai-alt-text 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

moritz-sauer-13/silverstripe-ai-alt-text

最新稳定版本:1.0

Composer 安装命令:

composer require moritz-sauer-13/silverstripe-ai-alt-text

包简介

Generate alt text for images via OpenAI Api

README 文档

README

Generates alt texts for images via OpenAI Vision API. Integrates seamlessly into the SilverStripe 6 CMS AssetAdmin — a native FormAction button triggers AI-based generation and saves the result directly.

Requires purplespider/asset-alt-text for the AltText field on Image assets.

Requirements

  • SilverStripe Framework ^6
  • purplespider/asset-alt-text ^3
  • openai-php/client ^0.18.0
  • PHP 8.1+

Installation

composer require moritz-sauer-13/silverstripe-ai-alt-text

Then run:

vendor/bin/sake dev/build flush=1

Configuration

API Key (required)

Set the OpenAI API key via environment variable (recommended) or YAML config.

Option 1: Environment variable (.env file or server config)

OPENAI_API_KEY="sk-your-api-key-here"

Option 2: YAML config (app/_config/ai-alt-text.yml)

AiAltText\Service\OpenAiVisionClient:
  api_key: 'sk-your-api-key-here'

Note: Environment variables take precedence over YAML config.

Optional Configuration

# Model selection (default: gpt-4o-mini)
AiAltText\Service\OpenAiVisionClient:
  model: 'gpt-4o'
  max_tokens: 300

# Image resize limits before sending to OpenAI (default: 1024x1024)
AiAltText\Service\AltTextGenerator:
  max_image_width: 1024
  max_image_height: 1024

Custom Prompt (SiteConfig)

The AI prompt can be customized directly in the CMS:

  1. Go to Settings in the CMS
  2. Click on the AI Alt Text tab
  3. Enter your custom prompt in the text field
  4. Save

The custom prompt allows you to:

  • Set the output language directly (e.g., "Write in German" or "Schreibe auf Deutsch")
  • Customize the style and length of generated alt texts
  • Add specific instructions for your content type

Example custom prompt (German):

Schreibe einen prägnanten, beschreibenden Alt-Text für dieses Bild auf Deutsch.

Regeln:
- Länge: 80-160 Zeichen, kürzer bei einfachen Bildern.
- Sei spezifisch und beschreibend.
- Beginne nicht mit "Bild von", "Foto von" oder ähnlichen Phrasen.
- Keine Marketing-Sprache.
- Gib NUR den Alt-Text zurück, nichts anderes.

Leave the field empty to use the default English prompt.

License

BSD-3-Clause

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固