Bug #89316
Improvement for default File Abstraction Layer (for section only)
0%
Description
hi
the default code for "Make default File Abstraction Layer (for section only)" can be improved a little bit IMHO.
Here are few points that can be improved:
1) because its used in section then the default number of images should be 1 instead of 5
2) there should be thumbnail generated
3) there should be as low number of unneeded info as possible
Please look for visual difference between current and proposal.
Here is my proposal for new default for "Make default File Abstraction Layer (for section only)".
<config>
<type>group</type>
<internal_type>db</internal_type>
<appearance>
<elementBrowserType>file</elementBrowserType>
<elementBrowserAllowed>gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai,svg</elementBrowserAllowed>
</appearance>
<allowed>sys_file</allowed>
<size>1</size>
<minitems>0</minitems>
<maxitems>1</maxitems>
<show_thumbs>0</show_thumbs>
<hideSuggest>1</hideSuggest>
<fieldWizard>
<tableList>
<disabled>true</disabled>
</tableList>
<sysFileThumbnail>
<renderType>SysFileThumbnail</renderType>
</sysFileThumbnail>
</fieldWizard>
<dce_load_schema>1</dce_load_schema>
<dce_get_fal_objects>1</dce_get_fal_objects>
</config>
It produces very small input with thumbnail.
However it needs new Node for rendering the thumbnail.
The registration of the node in ext_localconf.php as follow:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][14853511217] = [
'nodeName' => 'SysFileThumbnail',
'priority' => 30,
'class' => \Vendor\Extension\Backend\Form\FieldWizard\SysFileThumbnail::class
];
The node rendering itself:
<?php
declare(strict_types=1);
namespace Vendor\Extension\Backend\Form\FieldWizard;
use TYPO3\CMS\Backend\Form\AbstractNode;
use TYPO3\CMS\Core\Resource\ProcessedFile;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
/**
* Render thumbnails of sys_file. Used in DCE for thumbnails in file section.
*/
class SysFileThumbnail extends AbstractNode
{
/**
*
* @return array
* @throws \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException
*/
public function render(): array
{
$result = $this->initializeResultArray();
$parameterArray = $this->data['parameterArray'];
$selectedItems = $parameterArray['itemFormElValue'];
$fileFactory = ResourceFactory::getInstance();
$thumbnailsHtml = [];
foreach ($selectedItems as $selectedItem) {
$uid = $selectedItem['uid'];
if (MathUtility::canBeInterpretedAsInteger($uid)) {
$fileObject = $fileFactory->getFileObject($uid);
if (!$fileObject->isMissing()) {
$extension = $fileObject->getExtension();
if (GeneralUtility::inList(
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
$extension
)
) {
$thumbnailsHtml[] = '<li>';
$thumbnailsHtml[] = '<span class="thumbnail">';
$thumbnailsHtml[] = '<img src="/' .
$fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, ['width'=>250])->getPublicUrl(false) . '" />';
$thumbnailsHtml[] = '</span>';
$thumbnailsHtml[] = '</li>';
}
}
}
}
$html = [];
if (!empty($thumbnailsHtml)) {
$html[] = '<ul class="list-inline">';
$html[] = implode(LF, $thumbnailsHtml);
$html[] = '</ul>';
}
$result['html'] = implode(LF, $html);
return $result;
}
}
Files
Updated by Armin Vieweg 9 months ago
- Status changed from New to Rejected
This feature is not supported anymore, by DCE.
Try to avoid sections!