Php Symfony/liip_imagine:图像路径分辨率导致404

Php Symfony/liip_imagine:图像路径分辨率导致404,php,symfony,liipimaginebundle,Php,Symfony,Liipimaginebundle,服务器配置 Symfony 4.4.2 Apache 2.4.29 PHP: 7.3 Hosting: AWS LightSail 我使用liip_imagine捆绑包处理上传的图像,并使用asset()将它们显示在细枝模板中。不幸的是,图像URL解析为404,我不知道为什么 以下是相关的细枝模板: {{‘当前图像’| trans}} {%if module.image!=''%} {%endif%} 我检查了这个: 文件已正确上载到/public/upload文件夹中 module.i

服务器配置

Symfony 4.4.2
Apache 2.4.29
PHP: 7.3
Hosting: AWS LightSail
我使用liip_imagine捆绑包处理上传的图像,并使用
asset()
将它们显示在细枝模板中。不幸的是,图像URL解析为404,我不知道为什么

以下是相关的细枝模板:


{{‘当前图像’| trans}}

{%if module.image!=''%} {%endif%}
我检查了这个:

  • 文件已正确上载到/public/upload文件夹中
  • module.image不包含图像哈希名称和扩展名:
    da305b9a0fee3eb7bdc5bfc9b64e88ff.jpeg
  • 真正的url:
    /public/upload/da305b9a0fee3eb7bdc5bbc9b64e88ff.jpeg
  • 生成的url:
    https://domain.tld/media/cache/learningModuleImage/da305b9a0fee3eb7bdc5bfc9b64e88ff.jpeg

  • 配置:

我还检查了虚拟主机:


ServerName domain.tld
DocumentRoot/var/www/project/public
DirectoryIndex/index.php
允许超越所有
命令允许,拒绝
通融
选项-多视图
要求所有授权
FallbackResource/index.php
ErrorLog${APACHE_LOG_DIR}/error-project.LOG
CustomLog${APACHE_LOG_DIR}/access-project.LOG组合
#Include/etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile/etc/letsencrypt/live/domain.tld/fullchain.pem
SSLCertificateKeyFile/etc/letsencrypt/live/domain.tld/privkey.pem
Include/etc/letsencrypt/options-ssl-apache.conf
我解决了

这是工作配置。谢谢@MaulikParmar的提示


liip_imagine:
    loaders:
        default:
            filesystem:
                data_root:
                    - "%kernel.project_dir%/public/upload"
                    - "%kernel.project_dir%/public/assets/img"

    resolvers:
        default:
            web_path:
                web_root: "%kernel.project_dir%/public"
                cache_prefix: media/cache

    filter_sets:
        cache: ~
        learningModuleImage:
            cache: default
            filters:
                downscale:
                    max: [512, 512]
        profile:
            filters:
                downscale:
                    max: [512, 512]

        # the name of the "filter set"
        thumb:
            # adjust the image quality to 75%
            # quality: 75
            cache: default
            # list of transformations to apply (the "filters")
            filters:
                # create a thumbnail: set size to 120x90 and use the "outbound" mode
                # to crop the image when the size ratio of the input differs
                thumbnail: { size: [128, 128], mode: outbound }
                # create a 2px black border: center the thumbnail on a black background
                # 4px larger to create a 2px border around the final image
                # background: { size: [124, 94], position: center, color: '#000000' }
我解决了

这是工作配置。谢谢@MaulikParmar的提示


liip_imagine:
    loaders:
        default:
            filesystem:
                data_root:
                    - "%kernel.project_dir%/public/upload"
                    - "%kernel.project_dir%/public/assets/img"

    resolvers:
        default:
            web_path:
                web_root: "%kernel.project_dir%/public"
                cache_prefix: media/cache

    filter_sets:
        cache: ~
        learningModuleImage:
            cache: default
            filters:
                downscale:
                    max: [512, 512]
        profile:
            filters:
                downscale:
                    max: [512, 512]

        # the name of the "filter set"
        thumb:
            # adjust the image quality to 75%
            # quality: 75
            cache: default
            # list of transformations to apply (the "filters")
            filters:
                # create a thumbnail: set size to 120x90 and use the "outbound" mode
                # to crop the image when the size ratio of the input differs
                thumbnail: { size: [128, 128], mode: outbound }
                # create a 2px black border: center the thumbnail on a black background
                # 4px larger to create a 2px border around the final image
                # background: { size: [124, 94], position: center, color: '#000000' }

您是否尝试在特定筛选器集中传递默认冲突解决程序名称?您的配置没有在bundle级别指定cache,所以请尝试在liip_imagine config下定义cache:default,以便所有其他筛选器都继承它configuration@MaulikParmar谢谢你的建议。我尝试了你的建议,图像显示上仍然没有骰子,但现在生成的图像存储在/public/upload//media/cache/{filter}/文件夹中。据我所知,我以为它们会存储在/var/cache/prod/folder中。这正常吗?@MaulikParmar事实上,如果我能简单地在生成的路径前面加上“upload”,它就会工作。是否可以在整个包范围内执行此操作?可能会有一个输入错误,`should be``因为imgine过滤器应用于资产之上,而不是作为参数。啊,很好!您是否尝试在特定筛选器集中传递默认冲突解决程序名称?您的配置没有在bundle级别指定cache,所以请尝试在liip_imagine config下定义cache:default,以便所有其他筛选器都继承它configuration@MaulikParmar谢谢你的建议。我尝试了你的建议,图像显示上仍然没有骰子,但现在生成的图像存储在/public/upload//media/cache/{filter}/文件夹中。据我所知,我以为它们会存储在/var/cache/prod/folder中。这正常吗?@MaulikParmar事实上,如果我能简单地在生成的路径前面加上“upload”,它就会工作。是否可以在整个包范围内执行此操作?可能会有一个输入错误,`should be``因为imgine过滤器应用于资产之上,而不是作为参数。啊,很好!