FluidTYPO3\Vhs\Traits\SourceSetViewHelperTrait::getImgResource PHP Method

getImgResource() public method

generates a copy of a give image with a specific width
public getImgResource ( string $src, integer $width, string $format, string $quality, string $treatIdAsReference, array $params = null ) : string
$src string path of the image to convert
$width integer width to convert the image to
$format string format of the resulting copy
$quality string quality of the resulting copy
$treatIdAsReference string given src argument is a sys_file_reference record
$params array additional params for the image rendering
return string
    public function getImgResource($src, $width, $format, $quality, $treatIdAsReference, $params = null)
    {
        $setup = ['width' => $width, 'treatIdAsReference' => $treatIdAsReference];
        if (false === empty($format)) {
            $setup['ext'] = $format;
        }
        if (0 < intval($quality)) {
            $quality = MathUtility::forceIntegerInRange($quality, 10, 100, 75);
            $setup['params'] .= ' -quality ' . $quality;
        }
        if ('BE' === TYPO3_MODE && '../' === substr($src, 0, 3)) {
            $src = substr($src, 3);
        }
        return $this->contentObject->getImgResource($src, $setup);
    }