指尖上的记忆指尖上的记忆
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub

symfony处理图片的bundle,其中比较有用的就是生成缩略图,以及将图片缓存

composer require liip/imagine-bundle

安装过程中会让用户选择,这里选择y
然后项目会自动注入依赖,配置文件等,不需要手动引入

最后的配置文件在:  app/config/packages/liip_imagine.yaml 而不是demo里的 app/config/config.yml

//liip_imagine.yaml 添加需要的配置如下
# 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: "imagick"
    webp:
        generate: true
    filter_sets:
        squared_thumbnail_small:
            filters:
                thumbnail:
                    size: [200, 200]
                    mode: outbound
                    allow_upscale: true
    loaders:
        default:
            filesystem:
                data_root:
                    - "%kernel.project_dir%/public"


twig模板使用:src="{{ asset(course.coverPicture)|imagine_filter('squared_thumbnail_small') }}