diff --git a/Dockerfile b/Dockerfile index 3540f0f..fb19f37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,7 @@ RUN install-php-extensions \ sodium RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" +RUN printf '[PHP]\nupload_max_filesize=10M\npost_max_size=11M\n' > "$PHP_INI_DIR/conf.d/uploads.ini" RUN printf '[opcache]\nopcache.enable=1\nopcache.memory_consumption=256\nopcache.max_accelerated_files=20000\nopcache.validate_timestamps=0\n' \ > "$PHP_INI_DIR/conf.d/opcache.ini" diff --git a/src/Controller/ProfileController.php b/src/Controller/ProfileController.php index b3e2513..6d87543 100644 --- a/src/Controller/ProfileController.php +++ b/src/Controller/ProfileController.php @@ -27,6 +27,7 @@ use Doctrine\ORM\EntityManagerInterface; use League\Flysystem\FilesystemException; use League\Flysystem\FilesystemOperator; use Liip\ImagineBundle\Imagine\Cache\CacheManager; +use Liip\ImagineBundle\Service\FilterService; use Psr\Log\LoggerInterface; use RuntimeException; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -140,6 +141,7 @@ class ProfileController extends AbstractController Request $request, EntityManagerInterface $em, CacheManager $cacheManager, + FilterService $filterService, #[Autowire(service: 'mineseeker.media.storage')] FilesystemOperator $mediaStorage, ): JsonResponse { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); @@ -153,8 +155,8 @@ class ProfileController extends AbstractController return $this->json(['error' => 'No file uploaded.'], 400); } - if ($file->getSize() > 2 * 1024 * 1024) { - return $this->json(['error' => 'File is too large. Maximum 2 MB.'], 400); + if ($file->getSize() > 10 * 1024 * 1024) { + return $this->json(['error' => 'File is too large. Maximum 10 MB.'], 400); } $allowed = ['image/jpeg', 'image/png', 'image/gif', 'image/webp']; @@ -182,6 +184,7 @@ class ProfileController extends AbstractController $mediaStorage->writeStream($newPath, $stream); } catch (FilesystemException $e) { $this->logger->error('Unable to write new avatar: ' . $e->getMessage()); + fclose($stream); throw new RuntimeException('Unable to write new avatar: ' . $e->getMessage()); } fclose($stream); @@ -190,7 +193,7 @@ class ProfileController extends AbstractController $em->flush(); return $this->json([ - 'thumbUrl' => $cacheManager->generateUrl($newPath, 'avatar_thumb'), + 'thumbUrl' => $filterService->getUrlOfFilteredImage($newPath, 'avatar_thumb'), ]); } diff --git a/templates/Security/profile.html.twig b/templates/Security/profile.html.twig index a282975..a271db8 100644 --- a/templates/Security/profile.html.twig +++ b/templates/Security/profile.html.twig @@ -2,7 +2,9 @@ {% macro stat_val(value, suffix) %} {%- set abbr = value >= 1000 -%} - {% if abbr %}{{ (value / 1000)|round(1, 'floor') }}k{% else %}{{ value }}{% endif %}{% if suffix %}{{ suffix }}{% endif %} + {% if abbr %}{{ (value / 1000)|round(1, 'floor') }}k{% else %}{{ value }}{% endif %}{% if suffix %} + {{ suffix }}{% endif %} {% endmacro %} {% block title %} - Profile{% endblock %} @@ -31,7 +33,7 @@
@@ -134,11 +136,13 @@ {% set result = game.result %} {% set is_finished = game.resign is not null - or (my_points is not null and opp_points is not null - and (my_points > 25 or opp_points > 25)) %} + or (my_points is not null and opp_points is not null + and (my_points > 25 or opp_points > 25)) %} {% set is_anonymous = game.oppIsGuest %} -
+
{% if is_finished %} {{ result == 'win' ? 'Win' : (result == 'loss' ? 'Loss' : 'Draw') }}