菜单

Get File Relation

2015年02月13日 - extensions
//Here is a small snippet I use to get uploaded images from a content object (tt_content).

public function getContentImages($tt_content_uid) {
    /** @var \TYPO3\CMS\Core\Resource\FileRepository $fileRepository */
    $fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Resource\FileRepository');
    $fileObjects = $fileRepository->findByRelation('tt_content', 'image', $tt_content_uid);

    // Get file information
    $files = array();
    foreach ($fileObjects as $key => $value) {
        $file = array();
        $file['reference'] = $value->getReferenceProperties();
        $file['original'] = $value->getOriginalFile()->getProperties();
        $files[] = $file;
    }

    return $files;
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注