‪TYPO3CMS  10.4
MetaDataEventListener.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 
28 {
29  private const ‪TABLE_NAME = 'sys_file_metadata';
30 
35  {
36  $record = $event->‪getRecord();
37 
38  if (($record['width'] ?? 0) <= 0 || ($record['height'] ?? 0) <= 0) {
39  return;
40  }
41 
42  $metaData = [
43  'width' => (int)$record['width'],
44  'height' => (int)$record['height'],
45  ];
46 
47  // Update translated meta data records
48  $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable(self::TABLE_NAME);
49  $connection->update(
50  self::TABLE_NAME,
51  $metaData,
52  [
53  'file' => $event->‪getFileUid(),
54  'l10n_parent' => $event->‪getMetaDataUid(),
55  ]
56  );
57  }
58 }
‪TYPO3\CMS\Core\Resource\MetaDataEventListener\afterFileMetaDataUpdated
‪afterFileMetaDataUpdated(AfterFileMetaDataUpdatedEvent $event)
Definition: MetaDataEventListener.php:34
‪TYPO3\CMS\Core\Resource\Event\AfterFileMetaDataUpdatedEvent\getFileUid
‪getFileUid()
Definition: AfterFileMetaDataUpdatedEvent.php:44
‪TYPO3\CMS\Core\Resource\MetaDataEventListener
Definition: MetaDataEventListener.php:28
‪TYPO3\CMS\Core\Resource\Event\AfterFileMetaDataUpdatedEvent\getRecord
‪getRecord()
Definition: AfterFileMetaDataUpdatedEvent.php:54
‪TYPO3\CMS\Core\Resource
Definition: generateMimeTypes.php:52
‪TYPO3\CMS\Core\Resource\MetaDataEventListener\TABLE_NAME
‪const TABLE_NAME
Definition: MetaDataEventListener.php:29
‪TYPO3\CMS\Core\Resource\Event\AfterFileMetaDataUpdatedEvent\getMetaDataUid
‪getMetaDataUid()
Definition: AfterFileMetaDataUpdatedEvent.php:49
‪TYPO3\CMS\Core\Resource\Event\AfterFileMetaDataUpdatedEvent
Definition: AfterFileMetaDataUpdatedEvent.php:24
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46