liip / LiipImagineBundle

Symfony Bundle to assist in image manipulation using the imagine library
http://liip.ch
MIT License
1.66k stars 378 forks source link

Question about Loaders #1513

Closed genby8 closed 1 year ago

genby8 commented 1 year ago
  1. PHP Version 8.1.14
  2. GD 2.1.0 compatible
  3. Symfony 5.4.24
  4. liip/imagine-bundle 2.10.0

my real file path: /public/upload/my_media/filename.jpg

my config:

liip_imagine:
    resolvers:
        default:
            web_path:
                cache_prefix: "/upload/media/cache"
    loaders:
        default:
            filesystem:
                data_root:
                    photo: '/upload/my_media'
    filter_sets:
        cache: ~
        my_thumb:
            quality: 75
            filters:
                thumbnail: { size: [120, 90], mode: outbound }
                background: { size: [124, 94], position: center, color: '#000000' }

in Twig template use: {{ asset('@photo:filename.jpg')|imagine_filter('my_thumb') }}

result: https://my_domain/media/cache/resolve/my_thumb/@photo:filename.jpg

Photo not show. Why url not: https://my_domain/upload/media/cache/my_thumb/upload/my_media/filename.jpg

From documentation (here)

Given the above configuration, you can explicitly request a root path using the format @index:path/to/file.ext. For example, to request the file /a/foo/path/with/file.ext you can pass @foo:with/file.ext as the filename.

Or are loaders not for that? Or does this functionality no longer exist, but remains in documentation?

genby8 commented 1 year ago

I'm sorry. The question was worded incorrectly. Figured out why two different paths are generated. Due to the fact that the existence of the file on the disk is checked (as a result, the generation of different paths). I decided that when generating a feed of articles with an image gallery, and even with a retina, and with webp - as a result, checking the existence of files more than 1000 times is a bad option. Therefore, I corrected the route for liip_imagine_filter, so that the resulting images are generated and laid along the same path. And I use imagine_filter_cache.