fix avatar path for subdirectory installations (#1201)

This commit is contained in:
Kevin Papst
2019-10-30 14:00:48 +01:00
committed by GitHub
parent bda9584346
commit 48aefb1862
4 changed files with 7 additions and 7 deletions

View File

@@ -1,3 +1,6 @@
framework:
assets:
json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'
packages:
avatars:
base_path: 'avatars'

View File

@@ -29,6 +29,3 @@ framework:
#validation:
# possible values: 'loose', 'strict', 'html5'
#email_validation_mode: 'html5'
assets:
json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'

View File

@@ -54,6 +54,6 @@ class AvatarExtension extends AbstractExtension
return $this->packages->getUrl($default);
}
return $this->packages->getUrl($url);
return $this->packages->getUrl($url, 'avatars');
}
}

View File

@@ -110,14 +110,14 @@ class AvatarService
private function getAvatarUrl(User $profile): string
{
return '/avatars/' . md5($profile->getId() . '_' . $profile->getDisplayName()) . '.png';
return md5($profile->getId() . '_' . $profile->getDisplayName()) . '.png';
}
private function getImagePath(User $profile): string
{
$avatarPath = realpath($this->projectDirectory . '/public/');
$avatarPath = realpath($this->projectDirectory . '/public/avatars/');
return $avatarPath . $this->getAvatarUrl($profile);
return $avatarPath . '/' . $this->getAvatarUrl($profile);
}
public function generateAvatar(User $profile, bool $regenerate = false): bool