Beispiel #1
0
 /**
  * Creates the necessary images to be used as an avatar.
  *
  * @since	1.0
  * @access	public
  * @param	string		The target location to store the avatars
  * @return
  */
 public function create(&$avatarTable = null, $options = array())
 {
     // Get a list of files to build.
     $names = $this->generateFileNames();
     if (is_string($avatarTable)) {
         $targetLocation = $avatarTable;
     } else {
         $targetLocation = !empty($targetLocation) ? $targetLocation : $this->getPath();
     }
     foreach ($names as $size => $name) {
         $info = self::${$size};
         $image = $this->image->cloneImage();
         if ($info['mode'] == 'fill') {
             $image->fill($info['width'], $info['height']);
         }
         if ($info['mode'] == 'resize') {
             $image->resize($info['width'], $info['height']);
         }
         if ($info['mode'] == 'proportionate') {
             $image->width($info['width']);
         }
         $path = $targetLocation . '/' . $name;
         if (JFile::exists($path)) {
             JFile::delete($path);
         }
         $image->save($path);
         if ($avatarTable instanceof SocialTableAvatar) {
             $avatarTable->{$size} = $name;
         }
     }
     // Delete the tmp path once it's saved
     // Don't delete if options['deleteimage'] is specifically set to false
     if (!isset($options['deleteimage']) || $options['deleteimage'] != false) {
         $tmp = $image->getPath();
         if ($tmp) {
             JFile::delete($tmp);
         }
     }
     return $names;
 }