Permalink
Browse files

Added an additional twig method for creating new, empty images

  • Loading branch information...
1 parent 90d32f9 commit cbb5dc3c00766631fd6385455a7a8bf6cad05d1d Benjamin Zikarsky committed May 30, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 Extensions/ImageTwig.php
View
@@ -11,6 +11,7 @@
* ImageTwig extension
*
* @author Gregwar <g.passault@gmail.com>
+ * @author bzikarsky <benjamin.zikarsky@perbility.de>
*/
class ImageTwig extends \Twig_Extension
{
@@ -30,14 +31,20 @@ public function initRuntime(\Twig_Environment $environment)
public function getFunctions()
{
return array(
- 'image' => new \Twig_Function_Method($this, 'image', array('is_safe' => array('html')))
+ 'image' => new \Twig_Function_Method($this, 'image', array('is_safe' => array('html'))),
+ 'new_image' => new \Twig_Function_Method($this, 'newImage', array('is_safe' => array('html')))
);
}
public function image($path)
{
return $this->container->get('image.handling')->open($path);
}
+
+ public function newImage($width, $height)
+ {
+ return $this->container->get('image.handling')->create($width, $height);
+ }
public function getName()
{

0 comments on commit cbb5dc3

Please sign in to comment.