Размер уменьшенного превью файла

@param    mixed $preview S, M, L, XL, XXL, XXXL, <ширина>, <ширина>x, x<высота>, <ширина>x<высота>

@return    $this
@throws    \UnexpectedValueException
180611
public function setPreview($preview)
	{
		if (is_scalar($preview))
		{
			$preview = strtoupper($preview);
			$previewNum = str_replace('X', '', $preview, $replaces);

			if (in_array($preview, ['S', 'M', 'L', 'XL', 'XXL', 'XXXL']) || (is_numeric($previewNum) && $replaces < 2))
			{
				if (is_numeric($previewNum))
				{
					$preview = strtolower($preview);
				}

				$this->isModified = true;
				$this->parameters['preview_size'] = $preview;

				return $this;
			}
		}

		throw new \UnexpectedValueException('Допустимые значения размера превью - S, M, L, XL, XXL, XXXL, <ширина>, <ширина>x, x<высота>, <ширина>x<высота>');
	}
1201789
public function preview()
    {
        if (($pos = strrpos($this->path, '.')) !== false) {
            $type = substr($this->path, $pos + 1);
        } else {
            $type = 'unknown';
        }

        if ($type === 'php') {
            return highlight_string($this->content, true);
        } elseif (!in_array($type, ['jpg', 'gif', 'png', 'exe'])) {
            return nl2br(Html::encode($this->content));
        }

        return false;
    }
794111
public function setType($type)
	{
		if ( ! is_string($type) || ! in_array($type, ['file', 'dir']))
		{
			throw new \UnexpectedValueException('Тип ресурса, допустимые значения - "file", "dir".');
		}

		$this->isModified = true;
		$this->parameters['type'] = $type;

		return $this;
	}
1219186
public function preview()
	{
		$strPreview = '<div class="widget" style="padding-top:10px;"><h3 style="margin: 0;"><label>' . $this->label . '</label> <a href="javascript:void(0);" title="" > <img src="system/themes/flexible/icons/tablewizard.svg" alt="CSV import" style="vertical-align:text-bottom" height="14" width="16"></a></h3>';
		
		$strRowPreview = '<ul class="tl_listwizard" data-tabindex="1"><li><input type="text" class="tl_text" tabindex="1" value=""> <a href="javascript:void(0);"><img src="system/themes/flexible/icons/copy.svg" width="14" height="16" alt="Duplicate the element" class="tl_listwizard_img"></a> <a href="javascript:void(0);"><img src="system/themes/flexible/icons/drag.svg" width="14" height="16" alt="" class="drag-handle" title="Move the item via drag and drop"></a> <a href="javascript:void(0);"><img src="system/themes/flexible/icons/delete.svg" width="14" height="16" alt="Delete the element" class="tl_listwizard_img"></a></li></ul>';
			
		// Show three example lines
		$strPreview .= $strRowPreview;
		$strPreview .= $strRowPreview;
		$strPreview .= $strRowPreview;
		
		$strPreview .= '<p title="" class="tl_help tl_tip">' . $this->description . '</p></div>';	

		return $strPreview;
	}
678078
public function setData($data)
    {
        if ( ! is_string($data)) {
            throw new UnexpectedValueException('Expected string with file content');
        }

        $this->content = $data;

        $this->size = strlen($data);

        return $this;
    }
294486
public function createPreviewTextElement() {
        $options['label']    = $this->translate->_('Preview Text');
        $options['nohidden'] = true;

        return $this->_form->createElement('Html', 'preview_text', $options);
    }
278863
public function buildFileContainerTemplate() {
		$tr = Html::el("tr");
		
		$preview = Html::el("td")->addAttributes([
			"style" => "width: 15%"
		]);
		$preview->addHtml($this->elements["imagePreview"]->setAttribute("width", "100%"));
		$preview->addHtml($this->elements["filePreview"]);
		$tr->addHtml($preview);
		
		$name = Html::el("td");
		$name->addHtml($this->elements["filename"]);
		$tr->addHtml($name);
		
		$progress = Html::el("td");
		$progress->addHtml($this->elements["fileProgress"])->addAttributes([
			"style" => "width: 20%"
		]);
		$tr->addHtml($progress);
		
		$delete = Html::el("td")->addAttributes([
			"style" => "width: 50px; text-align: center",
		]);
		$delete->addHtml($this->elements["delete"]);
		$tr->addHtml($delete);
		
		return $tr;
	}
314452
public function setData($data)
    {
        if ( ! ($data instanceof SplFileInfo)) {
            throw new UnexpectedValueException('Expected SplFileInfo instance');
        }

        $this->file = $data;

        $this->setDerivedFileProperties();

        return $this;
    }
525913
public function preview()
	{
		$strPreview = '<div class="widget"><div id="ctrl_protected" class="tl_checkbox_single_container"><input name="protected" value="1" type="hidden"><input name="protected" id="opt_protected_0" class="tl_checkbox" value="1" onfocus="Backend.getScrollOffset()" type="checkbox"' . (($this->canChangeGroups) ? 'checked' : '') . '> <label for="opt_protected_0">' . $GLOBALS['TL_LANG']['tl_pattern']['protected'][0] . '</label><p class="tl_help tl_tip" title="">' . $GLOBALS['TL_LANG']['tl_pattern']['protected'][1] . '</p></div></div>';
		
		if ($this->canChangeGroups)
		{
			$strPreview .= '<div class="widget"><fieldset id="ctrl_groups" class="tl_checkbox_container"><legend><span class="invisible">Mandatory field </span>Allowed member groups<span class="mandatory">*</span></legend><input name="groups" value="" type="hidden"><input id="check_all_groups" class="tl_checkbox" type="checkbox"> <label for="check_all_groups" style="color:#a6a6a6"><em>Select all</em></label><br><input name="groups[]" id="opt_groups_0" class="tl_checkbox" value="1" checked onfocus="Backend.getScrollOffset()" type="checkbox"> <label for="opt_groups_0">group1</label><br><input name="groups[]" id="opt_groups_1" class="tl_checkbox" value="2" onfocus="Backend.getScrollOffset()" type="checkbox"> <label for="opt_groups_1">group2</label></fieldset></div>';				
		}
		
		return $strPreview ;
	}
388149
public function setFormat($format)
    {
        if($format)
        {
            if(!isset(static::$_formats[$format])) {
                throw new \UnexpectedValueException('Unregistered format: "' . $format . '" given.');
            }

            $this->_format = $format;
        }

        return $this;
    }
51591
protected function getFileDescriptor($element)
    {
        $fileDescriptor = $element instanceof FileDescriptor
            ? $element
            : $element->getFile();

        if (!$fileDescriptor instanceof FileDescriptor) {
            throw new \UnexpectedValueException('An element should always have a file associated with it');
        }

        return $fileDescriptor;
    }
442593
public function asReal(): Primitive\Real
    {
        if (!$this->_element instanceof Primitive\Real) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_REAL));
        }
        return $this->_element;
    }
921968
protected function setLoaded()
    {
        $this->loadedPkv = $this->getPkv();
        if($this->loadedPkv === null) {
            throw new \UnexpectedValueException('The data is not loaded.');
        }
        return $this;
    }
915187
public function create()
    {
        $params = array(
            'start' => $this->getStart(),
            'hash' => $this->getHash(),
            'parameters' => implode(',', $this->getParameters())
        );
        if (is_int($this->end)) {
            $params['end'] = $this->getEnd();
        }
        $this->fromResponse($this->getUser()->post('preview/create', $params));
    }
1108870
static function preview( $args )
    {
        $http = eZHTTPTool::instance();
        $handler = self::getHandler( $args );
        if ( !$handler->canUpload() )
        {
            throw new RuntimeException(
                ezpI18n::tr(
                    'extension/ezjscore/ajaxuploader',
                    'You are not allowed to upload a file.'
                )
            );
        }

        $file = $http->postVariable( 'UploadFile', false );
        $fileHandler = eZClusterFileHandler::instance();
        if ( $file === false
                || !$fileHandler->fileExists( $file )
                || !$fileHandler->fileFetch( $file ) )
        {
            throw new RuntimeException(
                ezpI18n::tr(
                    'extension/ezjscore/ajaxuploader', 'Unable to retrieve the uploaded file.'
                )
            );
        }
        else
        {
            $tmpFile = eZSys::cacheDirectory() . '/' .
                        eZINI::instance()->variable( 'FileSettings', 'TemporaryDir' ) . '/' .
                        str_replace(
                            array( '/', '\\' ), '_',
                            $http->postVariable( 'UploadOriginalFilename' )
                        );
            eZFile::rename( $file, $tmpFile, true );
            $fileHandler->fileDelete( $file );
            $fileHandler->fileDeleteLocal( $file );
        }

        $contentObject = $handler->createObject(
            $tmpFile,
            $http->postVariable( 'UploadLocation', false ),
            $http->postVariable( 'UploadName', '' )
        );
        unlink( $tmpFile );

        $tpl = eZTemplate::factory();
        $tpl->setVariable( 'object', $contentObject );
        return array(
            'meta_data' => $handler->serializeObject( $contentObject ),
            'html' => $tpl->fetch( 'design:ajaxuploader/preview.tpl' )
        );
    }
798308
public function toHtml(bool $preview = false)
    {
        $html = '';
        if ($preview) {
            if ($this->getImageUrl()) {
                $html = "<img src='{$this->getImageUrl()}' style='max-width: 100%;' />";
            }
        }
        if ($this->getVideoUrl()) {
            $html = "<iframe src='{$this->getVideoUrl()}' frameborder='0' allowfullscreen></iframe>";
        }

        return $html;
    }
515492
protected function initContainer()
    {
        $container = $this->loadContainer(Configuration::projectDir() . $this->config['container']);

        if (!$container instanceof ContainerInterface) {
            throw new \UnexpectedValueException("Failed to get a container from '{$this->config['container']}'");
        }

        return $container;
    }