---
title: "Feature: Decide what a profile image's metadata will be"
manual: "Academic Profiles"
version: "main"
source: "Changelog/3.0/Feature-ModifyProfileImageMetadataEvent.rst"
rendered: "2026-10-02T20:47:49+00:00"
---

# Feature: Decide what a profile image's metadata will be {#feature-modify-profile-image-metadata-event}

## Description {#description}

`\FGTCLB\AcademicPersons\Event\ModifyProfileImageMetadataEvent` announces
the metadata this extension is about to write for the image of a profile, and a
listener decides what is written. Whatever it leaves in `getMetadata()` is
the field map that reaches the database; an empty map writes nothing.

The event is dispatched for each of the two records that carry image metadata,
and `getTargetTable()` says which one is being written:

-   `sys_file_metadata`, the record of the file itself, written once by
    the frontend upload that created the file and only for the fields it found
    empty — `title`, `alternative` and, where
    [`typo3/cms-filemetadata`](https://packagist.org/packages/typo3/cms-filemetadata) adds it, `copyright`. This is the
    record an installation requiring file attributes reads, which is why the
    `File` is handed over rather than only its uid.
-   `sys_file_reference`, the profile's own relation row, written whenever
    the name of the profile record changes — from a backend save, a
    localization or a frontend edit.

Both records are handed over either way: `getFile()` is the file, whose
own metadata record is `$event->getFile()->getMetaData()`, and
`getFileReference()` the image relation of the profile.
`getRequest()` is the request the write happens in, and `null` where
there is none — on the command line, for instance.

Fields the target table does not declare are dropped before the write, so a
listener may set `copyright` unconditionally: without
[`typo3/cms-filemetadata`](https://packagist.org/packages/typo3/cms-filemetadata) the column does not exist and the value goes
nowhere. System fields are dropped as well, with a warning in the log: the
identity of the record, the relation it is part of, its localization, its
workspace and its enable columns are the `DataHandler`'s, and this event
writes metadata.

```php
#[AsEventListener(identifier: 'my-extension/add-image-copyright')]
public function __invoke(ModifyProfileImageMetadataEvent $event): void
{
    if ($event->getTargetTable() !== 'sys_file_metadata') {
        return;
    }
    $metadata = $event->getMetadata();
    $metadata['copyright'] = $metadata['alternative'] ?? '';
    $event->setMetadata($metadata);
}
```

## Impact {#impact}

Nothing changes without a listener: the composed name of the profile record is
written to the columns named above. With one, a project fills the columns its
own installation adds and requires — `right_of_use` of
[`fgtclb/file-required-attributes`](https://packagist.org/packages/fgtclb/file-required-attributes), a copyright composed differently,
a caption of its own.

A listener runs inside the write of the profile record, for a backend save from
within a `DataHandler` hook. It has to be short, and it must not write
profile records itself.
