code/Controller/AssetAdmin.php
public function getMinimalistObjectFromData(File $file, $thumbnailLinks = true)
    {
        $object = array(
            'id' => (int) $file->ID,
            'parent' => null,
            'title' => $file->Title,
            'exists' => $file->exists(), // Broken file check
            'category' => $file instanceof Folder ? 'folder' : $file->appCategory(),
            'extension' => $file->Extension,
            'size' => $file->AbsoluteSize,
            'published' => ($file->hasMethod('isPublished')) ? $file->isPublished() : true,
            'modified' => ($file->hasMethod('isModifiedOnDraft')) ? $file->isModifiedOnDraft() : false,
            'draft' => ($file->hasMethod('isOnDraftOnly')) ? $file->isOnDraftOnly() : false,
        );

        /** @var Folder $parent */
        $parent = $file->Parent();

        if ($parent) {
            $object['parent'] = array(
                'id' => $parent->ID,
                'title' => $parent->Title,
                'filename' => $parent->Filename,
            );
        }

        /** @var File $file */
        if ($file->getIsImage()) {
            $thumbnails = $this->generateThumbnails($file, $thumbnailLinks);

            if ($thumbnailLinks) {
                $object = array_merge($object, $thumbnails);
            }
            // Save dimensions
            $object['width'] = $file->getWidth();
            $object['height'] = $file->getHeight();
        } else {
            $object['thumbnail'] = $file->PreviewLink();
        }

        return $object;
    }
public function getMinimalistObjectFromData(File $file, $thumbnailLinks = true)
    {
        $object = array(
            'id' => (int) $file->ID,
            'parent' => null,
            'title' => $file->Title,
            'exists' => $file->exists(), // Broken file check
            'category' => $file instanceof Folder ? 'folder' : $file->appCategory(),
            'extension' => $file->Extension,
            'size' => $file->AbsoluteSize,
            'published' => ($file->hasMethod('isPublished')) ? $file->isPublished() : true,
            'modified' => ($file->hasMethod('isModifiedOnDraft')) ? $file->isModifiedOnDraft() : false,
            'draft' => ($file->hasMethod('isOnDraftOnly')) ? $file->isOnDraftOnly() : false,
        );

        /** @var Folder $parent */
        $parent = $file->Parent();

        if ($parent) {
            $object['parent'] = array(
                'id' => $parent->ID,
                'title' => $parent->Title,
                'filename' => $parent->Filename,
            );
        }

        /** @var File $file */
        if ($file->getIsImage()) {
            $thumbnails = $this->generateThumbnails($file, $thumbnailLinks);

            if ($thumbnailLinks) {
                $object = array_merge($object, $thumbnails);
            }
            // Save dimensions
            $object['width'] = $file->getWidth();
            $object['height'] = $file->getHeight();
        } else {
            $object['thumbnail'] = $file->PreviewLink();
        }

        return $object;
    }
public function getMinimalistObjectFromData ( File $ file , $ thumbnailLinks = true ) { $ object = array ( 'id' => ( int ) $ file -> ID , 'parent' => null , 'title' => $ file -> Title , 'exists' => $ file -> exists ( ) , // Broken file check 'category' => $ file instanceof Folder ? 'folder' : $ file -> appCategory ( ) , 'extension' => $ file -> Extension , 'size' => $ file -> AbsoluteSize , 'published' => ( $ file -> hasMethod ( 'isPublished' ) ) ? $ file -> isPublished ( ) : true , 'modified' => ( $ file -> hasMethod ( 'isModifiedOnDraft' ) ) ? $ file -> isModifiedOnDraft ( ) : false , 'draft' => ( $ file -> hasMethod ( 'isOnDraftOnly' ) ) ? $ file -> isOnDraftOnly ( ) : false , ) ; /** @var Folder $parent */ $ parent = $ file -> Parent ( ) ; if ( $ parent ) { $ object [ 'parent' ] = array ( 'id' => $ parent -> ID , 'title' => $ parent -> Title , 'filename' => $ parent -> Filename , ) ; } /** @var File $file */ if ( $ file -> getIsImage ( ) ) { $ thumbnails = $ this -> generateThumbnails ( $ file , $ thumbnailLinks ) ; if ( $ thumbnailLinks ) { $ object = array_merge ( $ object , $ thumbnails ) ; } // Save dimensions $ object [ 'width' ] = $ file -> getWidth ( ) ; $ object [ 'height' ] = $ file -> getHeight ( ) ; } else { $ object [ 'thumbnail' ] = $ file -> PreviewLink ( ) ; } return $ object ; }
Build the array containing the minimal attributes needed to render an UploadFieldItem.

@param File $file
@param bool $thumbnailLinks Set to true if thumbnail links should be included.
Set to false to skip thumbnail link generation.
Note: Thumbnail content is always generated to pre-optimise for future use, even if
links are not generated.
@return array
Build the array containing the minimal attributes needed to render an UploadFieldItem .