Ejemplo n.º 1
0
 public function __invoke($accessor = null)
 {
     $this->restricted($accessor);
     return function ($src, $size = null, $flags = null, $pos = "0% 0%") {
         if ($flags) {
             $flags = array_reduce(preg_split('/[|,]/', $flags, -1, PREG_SPLIT_NO_EMPTY), function ($acc, $v) {
                 return $acc |= constant(self::IMAGE_HELPER_CLASS . '::' . $v);
             }, 0);
         }
         $img = new Img($src, $size, $flags, $pos);
         return array('src' => $img->getSrc());
     };
 }
Ejemplo n.º 2
0
 function preview($accessor)
 {
     $this->restricted($accessor);
     return function ($path, $size = '250x250') {
         $this->setCWN($path);
         $mime = self::getMime($this->cwn);
         $result = array('type' => $mime[0]);
         switch ($mime[0]) {
             case 'image':
                 $flags = Image::FIT;
                 if ($this->privated) {
                     $flags |= Image::PRIVATED;
                 }
                 // Not really needed
                 $img = new Image($this->rcwn, $size, $flags);
                 $result['src'] = $img->getSrc();
                 break;
         }
         return $result;
     };
 }