SettingsController::saveDefaultAvatars PHP Method

saveDefaultAvatars() private method

p* : The profile-sized image, which is constrained by Garden.Profile.MaxWidth and Garden.Profile.MaxHeight. n* : The thumbnail-sized image, which is constrained and cropped according to Garden.Thumbnail.Size.
private saveDefaultAvatars ( string $source, array $thumbOptions ) : boolean
$source string The path to the local copy of the image.
$thumbOptions array The options to save the thumbnail-sized avatar with.
return boolean Whether the saves were successful.
    private function saveDefaultAvatars($source, $thumbOptions)
    {
        try {
            $upload = new Gdn_UploadImage();
            // Generate the target image name
            $targetImage = $upload->generateTargetName(PATH_UPLOADS);
            $imageBaseName = pathinfo($targetImage, PATHINFO_BASENAME);
            // Save the full size image.
            $parts = Gdn_UploadImage::saveImageAs($source, self::DEFAULT_AVATAR_FOLDER . '/' . $imageBaseName);
            // Save the profile size image.
            Gdn_UploadImage::saveImageAs($source, self::DEFAULT_AVATAR_FOLDER . "/p{$imageBaseName}", c('Garden.Profile.MaxHeight', 1000), c('Garden.Profile.MaxWidth', 250), array('SaveGif' => c('Garden.Thumbnail.SaveGif')));
            $thumbnailSize = c('Garden.Thumbnail.Size', 40);
            // Save the thumbnail size image.
            Gdn_UploadImage::saveImageAs($source, self::DEFAULT_AVATAR_FOLDER . "/n{$imageBaseName}", $thumbnailSize, $thumbnailSize, $thumbOptions);
        } catch (Exception $ex) {
            $this->Form->addError($ex);
            return false;
        }
        $imageBaseName = $parts['SaveName'];
        saveToConfig('Garden.DefaultAvatar', $imageBaseName);
        return true;
    }