## rendering responsive Images variants
You can use the srcset argument to generate several differently sized
versions of this image that will be added as a srcset argument to the img tag.
enter a list of widths in the srcset to genereate copies of the same crop +
ratio but in the specified widths. Put the width at the start that you want
to use as a fallback to be shown when no srcset functionality is supported.
### Example
### Browser Support
To have the widest Browser-Support you should consider using a polyfill like:
http://scottjehl.github.io/picturefill/
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('path', 'string', 'DEPRECATED: Use src instead'); $this->registerArgument('minWidth', 'integer', 'DEPRECATED: Use minW instead'); $this->registerArgument('minHeight', 'integer', 'DEPRECATED: Use minH instead'); $this->registerArgument('maxWidth', 'integer', 'DEPRECATED: Use maxW instead'); $this->registerArgument('maxHeight', 'integer', 'DEPRECATED: Use maxH instead'); $this->registerArgument('density', 'integer', 'Canvas resolution for rendering the PDF in dpi (higher means better quality)', false, 100); $this->registerArgument('background', 'string', 'Fill background of resulting image with this color (for transparent source files)'); $this->registerArgument('rotate', 'integer', 'Number of degress to rotate resulting image by (caution: very slow if not multiple of 90)', false, 0); $this->registerArgument('page', 'integer', 'Optional page number to render as thumbnail for PDF documents with multiple pages', false, 1); $this->registerArgument('forceOverwrite', 'boolean', 'Forcibly overwrite existing converted PDF files', false, false); }
/** * @return string */ public function render() { $path = GeneralUtility::getFileAbsFileName($this->arguments['path']); if (FALSE === file_exists($path)) { return NULL; } $density = $this->arguments['density']; $rotate = $this->arguments['rotate']; $page = intval($this->arguments['page']); $background = $this->arguments['background']; $forceOverwrite = (bool) $this->arguments['forceOverwrite']; $width = $this->arguments['width']; $height = $this->arguments['height']; $minWidth = $this->arguments['minWidth']; $minHeight = $this->arguments['minHeight']; $maxWidth = $this->arguments['maxWidth']; $maxHeight = $this->arguments['maxHeight']; $filename = basename($path); $pageArgument = $page > 0 ? $page - 1 : 0; $colorspace = TRUE === isset($GLOBALS['TYPO3_CONF_VARS']['GFX']['colorspace']) ? $GLOBALS['TYPO3_CONF_VARS']['GFX']['colorspace'] : 'RGB'; $destination = GeneralUtility::getFileAbsFileName('typo3temp/vhs-pdf-' . $filename . '-page' . $page . '.png'); if (FALSE === file_exists($destination) || TRUE === $forceOverwrite) { $arguments = '-colorspace ' . $colorspace; if (0 < intval($density)) { $arguments .= ' -density ' . $density; } if (0 !== intval($rotate)) { $arguments .= ' -rotate ' . $rotate; } $arguments .= ' "' . $path . '"[' . $pageArgument . ']'; if (NULL !== $background) { $arguments .= ' -background "' . $background . '" -flatten'; } $arguments .= ' "' . $destination . '"'; $command = CommandUtility::imageMagickCommand('convert', $arguments); CommandUtility::exec($command); } $image = substr($destination, strlen(PATH_site)); return parent::render($image, $width, $height, $minWidth, $minHeight, $maxWidth, $maxHeight); }