5

メディアファイルのアップロードにVichUploaderBundleを使用しており、AvalancheImagineBundleを使用してテンプレートにサムを作成したいと考えています。それはどのように行われるべきですか?

私は今これを持っています:

<td><img src="{{ vich_uploader_asset(entity, 'image') | apply_filter('my_thumb')}}" alt="{{ entity.nombre }}" /></td>

しかし、出力は次のとおりです。

<img src="/app_dev.php/media/cache/my_thumb/images/uploads/392158_10150441208223772_580903771_8591661_774015725_n.jpg" alt="Froga"/>

これは私のconfig.ymlです:

# Vich Uploader
vich_uploader:
    db_driver: orm
    twig: true
    gaufrette: false # set to true to enable gaufrette support
    storage: vich_uploader.storage.file_system
    mappings:
        uploads:
            uri_prefix: /images/uploads
            upload_destination: %kernel.root_dir%/../web/images/uploads
            namer: ~ # specify a file namer service id for this entity, null default
            directory_namer: ~ # specify a directory namer service id for this entity, null default
            delete_on_remove: true # determines whether to delete file upon removal of entity
            inject_on_load: true # determines whether to inject a File instance upon load

avalanche_imagine:
    source_root:  %kernel.root_dir%/../web/images/uploads
    web_root:     %kernel.root_dir%/../web/images/uploads
    cache_prefix: media/cache
    driver:       gd
    filters:
        my_thumb:
            type:    thumbnail
            options: { size: [120, 90], mode: outbound, quality: 100, format: png }

何か助けや手がかりはありますか?

4

3 に答える 3

2

画像が表示されないという問題がある場合は、同じ問題が発生しました。

これを解決するために、config.yml内でavalanche_imagineのsource_rootandweb_rootオプションが%kernel.root_dir%/../web(またはWebルート)に設定されていることを確認しました。これが私のconfig.ymlからの関連するスニペットです:

#Uploads
knp_gaufrette:
    adapters:
        article_adapter:
            local:
                directory: %kernel.root_dir%/../web/images/articles
    filesystems:
        article_image_fs:
            adapter:    article_adapter
vich_uploader:
    db_driver: orm
    gaufrette: true
    storage: vich_uploader.storage.gaufrette
    mappings:
        article_image:
            uri_prefix: /images/articles
            upload_destination: article_image_fs
            namer: vich_uploader.namer_uniqid

#images
avalanche_imagine:
    filters:
        article_list:
            type:    thumbnail
            options: { size: [100, 100], mode: outbound }
    source_root:  %kernel.root_dir%/../web
    web_root:     %kernel.root_dir%/../web
    cache_prefix: cache
于 2013-02-21T14:24:17.720 に答える
0

それは何も悪いことではありません。本番環境のバンドルが最初に呼び出されたときにサムネイルを生成し、それをWeb/メディアフォルダーに保存することを想像してみてください。2回目の呼び出しでは、Web/メディアから読み取るだけです。ツムネイルのサイズを自由に変更できるという利点があります。パフォーマンスが心配な場合は、アップロードが完了した後にサムネイルを生成するためのジョブを実行する必要がありますが、私はそれをそのように使用し、文句を言うことはありませんでした。

于 2012-10-10T18:52:20.713 に答える
0

私の場合、LiipImagineBundleのフォークであるを使用することにしましたAvalancheImagineBundle

私はこのバンドルをデータローダーとして使用するように構成しました。パスをあまり気にせずに、説明どおりに使用するのは簡単ではありません。

于 2013-09-19T13:12:47.953 に答える