I have an older TYPO3 site that uses image pickers with the following code:
'tx_my_image' => array(
'label' => 'Image',
'exclude' => 1,
'config' => array(
'type' => 'group',
'internal_type' => 'file_reference',
'allowed' => 'gif,jpg,jpeg,png',
'show_thumbs' => 1,
'size' => 1,
'maxitems' => 1,
'minitems' => 0,
)
),
This does not work anymore in TYPO3:
10 (Error: "TCA internal type of field
tx_my_image
in table pages must be set to "db" or "folder".")
So, I changed it to look like this:
'tx_my_image' => array(
'label' => 'Image',
'exclude' => 1,
'config' => ExtensionManagementUtility::getFileFieldTCAConfig('tx_my_image', [
'show_thumbs' => 1,
'size' => 1,
'maxitems' => 1,
'minitems' => 0
], 'gif,jpg,jpeg,png'),
),
This works because the backend no longer throws fatal errors, but my problem now is that all the previously selected images are no longer found. Before, the path of the images was stored in a field tx_my_image
in the pages table (it's probably not a good idea to do that, but it was like this already when I started maintaining the site).
This site has many pages, so manually redoing all the image selections is unfeasible. So my question is, is there a way to either convert my old data to whatever format the new TYPO3 version expects or, better yet, to configure the form to find the data in its current form?
The "whatever format the new typo3 version expects" is a File Abstraction Layer relation, introduced in the "new version" TYPO3 6.2 8 years ago (released on 25.03.2014) ;)
So, the basics of FAL e.g. Upgrading to FAL can be read in the docs.
There are several solutions, but most of them need to be adapted/configured for your custom extension:
1. Extension "connetation:// FAL Migration"
This extension (for TYPO3 6.2) could help to migrate to FAL. https://extensions.typo3.org/extension/conn_falmigration
2. Have a look into EXT:news
Georg has extracted the former migration code (for hist EXT:news) to an extra extension. Looking into the code could show, which steps have to be done. https://packagist.org/packages/georgringer/news-fal-migration
3. Mostly be manual
With a little PHP script it can be handled:
Input data is the uid of the record and the path to your file. That path has to be in a form that is now used as identifier
-columns in the new table sys_file
.
<?php
// each line: recordUid;pathOfFile
$csv = "1;/user_upload/test.pdf
2;/user_upload/image.jpg";
$lines = str_getcsv($csv, chr(10));
$pid = 123;
foreach ($lines as $line) {
$row = str_getcsv($line, ';');
$row = array_map('trim', $row);
$uid = $row[0];
$filePath = $row[1];
if ($filePath && $filePath !== '""') {
$uid = trim($uid);
echo "INSERT INTO sys_file_reference (pid, uid_local, uid_foreign, tablenames, fieldname, table_local) VALUES($pid, (SELECT uid FROM sys_file WHERE identifier=\"" . $filePath . "\"), $uid, 'yourTable ', 'tx_my_image', 'sys_file');" . chr(10);
}
}
This will generate SQL-Queries for inserting the needed FAL relations.