我使用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 }有什么帮助或线索吗?
发布于 2013-02-21 22:24:18
如果您遇到的问题是没有显示图像,那么我也遇到了同样的问题。
为了解决这个问题,我确保在我的config.yml中,avalanche_imagine的source_root和web_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发布于 2012-10-11 02:52:21
这没什么错。想象一下,产品中的捆绑包在第一次调用时生成缩略图,并将其存储在web/media文件夹中。在第二次调用时,它只是从web/media读取。它有一些优点,可以随意修改缩略图的大小。如果你担心性能,你应该在上传完成后解雇一些作业来生成缩略图,尽管我是这样使用的,从来没有抱怨过。
发布于 2013-09-19 21:12:48
在我的例子中,我选择使用LiipImagineBundle,它是AvalancheImagineBundle的一个分支。
我将这个捆绑包配置为使用gaufrette作为数据加载器,而不是太关心路径,使用起来比你描述的更简单。
https://stackoverflow.com/questions/12826071
复制相似问题