public static function register(\Texy $texy, ImagePipe $imagePipe) { $texy->addHandler("image", function (\TexyHandlerInvocation $invocation, \TexyImage $image, $link) use($imagePipe) { $arguments = Helpers::prepareMacroArguments($image->URL); try { $image->URL = $imagePipe->setNamespace($arguments["namespace"])->request($arguments["name"], $arguments["size"], $arguments["flags"], TRUE); } catch (FileNotFoundException $e) { $image->URL = $arguments["name"]; if (!empty($arguments["size"])) { list($image->width, $image->height) = explode("x", $arguments["size"]); } } return $invocation->proceed($image, $link); }); }
public function createTemplate(Control $control = NULL) { if ($control === NULL) { $control = $this->application->presenter; } $template = $this->templateFactory->createTemplate($control); $template->_imagePipe = $this->imagePipe; $template->locale = isset($control->getPresenter()->locale) ? $control->getPresenter()->locale : NULL; $template->addFilter('file', function ($path) { return $this->imagePipe->getPath() . '/' . $path; }); $template->addFilter('mangleEmail', function ($mail) { $parts = str_split($mail); $str = ''; foreach ($parts as $item) { $str .= '&#' . ord($item) . ";"; } return $str; }); return $template; }
/** * @param \Texy|\Texy\Texy $texy * @param ImagePipe $imagePipe */ public static function register($texy, ImagePipe $imagePipe) { if (!$texy instanceof \Texy && !$texy instanceof \Texy\Texy) { throw new \InvalidArgumentException('The $texy parameter is not instance of Texy or Texy\\Texy'); } $texy->addHandler("image", function ($invocation, $image, $link) use($imagePipe) { if (!$invocation instanceof \TexyHandlerInvocation && !$invocation instanceof \Texy\HandlerInvocation) { throw new \InvalidArgumentException('The $invocation parameter is not instance of TexyHandlerInvocation or Texy\\HandlerInvocation'); } if (!$image instanceof \TexyImage && !$image instanceof \Texy\Image) { throw new \InvalidArgumentException('The $image parameter is not instance of TexyImage or Texy\\Image'); } $arguments = Helpers::prepareMacroArguments($image->URL); try { $image->URL = $imagePipe->setNamespace($arguments["namespace"])->request($arguments["name"], $arguments["size"], $arguments["flags"], TRUE); } catch (FileNotFoundException $e) { $image->URL = $arguments["name"]; if (!empty($arguments["size"])) { list($image->width, $image->height) = explode("x", $arguments["size"]); } } return $invocation->proceed($image, $link); }); }
/** * @param ImagePipe $imagePipe */ public function __construct(ImagePipe $imagePipe) { $this->assetsDir = $imagePipe->getAssetsDir(); $this->originalPrefix = $imagePipe->getOriginalPrefix(); $this->generatedDirs = array($imagePipe->getOriginalPrefix(), '[0-9]_[0-9]*x[0-9]*'); }