xanweb / c5-foundation

ConcreteCMS 基础框架

v2.1.5 2024-09-27 08:48 UTC

README

Latest Version on Packagist Software License

安装

将库添加到 composer.json 文件

composer require xanweb/c5-foundation

如何使用图像数据提取器

数据提取器尝试使用 IPTC 和 EXIF 元数据来填充图像信息。

application/config/app.php 中注册导入处理器

return [
    /*
     * Importer processors
     */
    'import_processors' => [
        'xw.image.data_extractor' => \Xanweb\C5\Foundation\File\Import\Processor\DataExtractor::class,
    ],
];

然后,您需要将图像信息映射到属性或属性。

以下是可用的信息键列表

  • image_title:图像标题
  • artist:艺术家名称
  • author_title:作者名称
  • 关键词
  • image_description:图像描述
  • 评论
  • 版权

默认映射如下

[
    'image_title' => 'title', // mapped to file title property
    'comments' => 'description', // mapped to file description property
    'keywords' => 'tags', // mapped to file tags property
]

要覆盖默认映射,您需要将 xanweb.php 配置文件添加到 /application/config 之下。
以下是一个可能的映射示例

<?php

return [
    'file_manager' => [
        'images' => [
            'data_extractor' => [
                'image_title' => ['title', 'ak_alt'], // You can use multiple properties/attributes per field.
                'comments' => 'description',
                'keywords' => 'tags',
                'author_title' => 'ak_author', // Use 'ak_' prefix for attributes.
                'copyright' => 'ak_copyright',
            ]
        ],
    ],
];