Skip to content

Commit

Permalink
Add image compression
Browse files Browse the repository at this point in the history
  • Loading branch information
AchillesKal committed Apr 7, 2024
1 parent 278794d commit b7607e6
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@

/assets/styles/app.tailwind.css
/public/uploads/

###> liip/imagine-bundle ###
/public/media/cache/
###< liip/imagine-bundle ###
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ RUN set -eux; \
intl \
opcache \
zip \
gd \
;

# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.1",
"exercise/htmlpurifier-bundle": "^5.0",
"liip/imagine-bundle": "^2.12",
"pagerfanta/doctrine-orm-adapter": "^4.3",
"pagerfanta/twig": "^4.3",
"runtime/frankenphp-symfony": "^0.2.0",
Expand Down
167 changes: 166 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
Symfonycasts\TailwindBundle\SymfonycastsTailwindBundle::class => ['all' => true],
Symfony\UX\Autocomplete\AutocompleteBundle::class => ['all' => true],
Exercise\HTMLPurifierBundle\ExerciseHTMLPurifierBundle::class => ['all' => true],
Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
];
8 changes: 8 additions & 0 deletions config/packages/liip_imagine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Documentation on how to configure the bundle can be found at: https://symfony.com/doc/current/bundles/LiipImagineBundle/basic-usage.html
liip_imagine:
# valid drivers options include "gd" or "gmagick" or "imagick"
driver: "gd"

filter_sets:
blog_list:
quality: 75
2 changes: 2 additions & 0 deletions config/routes/liip_imagine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_liip_imagine:
resource: "@LiipImagineBundle/Resources/config/routing.yaml"
13 changes: 13 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@
"config/packages/exercise_html_purifier.yaml"
]
},
"liip/imagine-bundle": {
"version": "2.12",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "1.8",
"ref": "d1227d002b70d1a1f941d91845fcd7ac7fbfc929"
},
"files": [
"config/packages/liip_imagine.yaml",
"config/routes/liip_imagine.yaml"
]
},
"phpunit/phpunit": {
"version": "9.6",
"recipe": {
Expand Down
2 changes: 1 addition & 1 deletion templates/blog_post/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<figure class="relative">
{# Check if the blog post has a banner image #}
{% if blog_post.banner %}
<img src="{{ asset(uploaded_asset(blog_post.banner)) }}" alt="{{ blog_post.title }}" class="h-full w-full rounded-3xl object-cover">
<img src="{{ asset(uploaded_asset(blog_post.banner)) | imagine_filter('blog_list') }}" alt="{{ blog_post.title }}" class="h-full w-full rounded-3xl object-cover">
{% else %}
<div class="min-h-full h-72 flex justify-center items-center bg-gray-200 rounded-3xl fill-gray-500">
<svg xmlns="http://www.w3.org/2000/svg" height="54" viewBox="0 -960 960 960" width="54">
Expand Down

0 comments on commit b7607e6

Please sign in to comment.