concrete/src/Entity/File/Version.php
public function importThumbnail(ThumbnailTypeVersion $version, $path)
    {
        $app = Application::getFacadeApplication();
        $config = $app->make('config');
        $thumbnailPath = $version->getFilePath($this);
        $filesystem = $this->getFile()
            ->getFileStorageLocationObject()
            ->getFileSystemObject();
        try {
            if ($filesystem->has($thumbnailPath)) {
                $filesystem->delete($thumbnailPath);
            }
        } catch (FileNotFoundException $e) {
        }
        $fileContents = file_get_contents($path);
        $mimeType = Util::guessMimeType($path, $fileContents);
        $filesystem->write(
            $thumbnailPath,
            $fileContents,
            [
                'visibility' => AdapterInterface::VISIBILITY_PUBLIC,
                'mimetype' => $mimeType,
            ]
        );

        if ($version->getHandle() == $config->get('concrete.icons.file_manager_listing.handle')) {
            $this->fvHasListingThumbnail = true;
        }

        if ($version->getHandle() == $config->get('concrete.icons.file_manager_detail.handle')) {
            $this->fvHasDetailThumbnail = true;
        }

        $this->save();
    }
public function importThumbnail(ThumbnailTypeVersion $version, $path)
    {
        $app = Application::getFacadeApplication();
        $config = $app->make('config');
        $thumbnailPath = $version->getFilePath($this);
        $filesystem = $this->getFile()
            ->getFileStorageLocationObject()
            ->getFileSystemObject();
        try {
            if ($filesystem->has($thumbnailPath)) {
                $filesystem->delete($thumbnailPath);
            }
        } catch (FileNotFoundException $e) {
        }
        $fileContents = file_get_contents($path);
        $mimeType = Util::guessMimeType($path, $fileContents);
        $filesystem->write(
            $thumbnailPath,
            $fileContents,
            [
                'visibility' => AdapterInterface::VISIBILITY_PUBLIC,
                'mimetype' => $mimeType,
            ]
        );

        if ($version->getHandle() == $config->get('concrete.icons.file_manager_listing.handle')) {
            $this->fvHasListingThumbnail = true;
        }

        if ($version->getHandle() == $config->get('concrete.icons.file_manager_detail.handle')) {
            $this->fvHasDetailThumbnail = true;
        }

        $this->save();
    }
public function importThumbnail ( ThumbnailTypeVersion $ version , $ path ) { $ app = Application :: getFacadeApplication ( ) ; $ config = $ app -> make ( 'config' ) ; $ thumbnailPath = $ version -> getFilePath ( $ this ) ; $ filesystem = $ this -> getFile ( ) -> getFileStorageLocationObject ( ) -> getFileSystemObject ( ) ; try { if ( $ filesystem -> has ( $ thumbnailPath ) ) { $ filesystem -> delete ( $ thumbnailPath ) ; } } catch ( FileNotFoundException $ e ) { } $ fileContents = file_get_contents ( $ path ) ; $ mimeType = Util :: guessMimeType ( $ path , $ fileContents ) ; $ filesystem -> write ( $ thumbnailPath , $ fileContents , [ 'visibility' => AdapterInterface :: VISIBILITY_PUBLIC , 'mimetype' => $ mimeType , ] ) ; if ( $ version -> getHandle ( ) == $ config -> get ( 'concrete.icons.file_manager_listing.handle' ) ) { $ this -> fvHasListingThumbnail = true ; } if ( $ version -> getHandle ( ) == $ config -> get ( 'concrete.icons.file_manager_detail.handle' ) ) { $ this -> fvHasDetailThumbnail = true ; } $ this -> save ( ) ; }
Import an existing file as a thumbnail type version.

@param \Concrete\Core\File\Image\Thumbnail\Type\Version $version
@param string $path
Import an existing file as a thumbnail type version .