我安装捆绑包。 LiipImagineBundle制作缩略图但它不起作用。
这是我的安装:
在Appkernel上
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
// My admin bundle
new AdminBundle\AdminBundle(),
// These are the other bundles the SonataAdminBundle relies on
new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Liip\ImagineBundle\LiipImagineBundle(),
// And finally, the storage and SonataAdminBundle
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new UserBundle\UserBundle(),
new FOS\UserBundle\FOSUserBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle()
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
在我的app / config.yml
之后liip_imagine:
resolvers:
default:
web_path: ~
filter_sets:
cache: ~
avatar:
quality: 75
filters:
thumbnail: { size: [120, 90], mode: outbound }
然后我的路由:
_liip_imagine:
resource: "@LiipImagineBundle/Resources/config/routing.yaml"
我做的最后一件事,在我的树枝上放了过滤器
{% for image in object.image %}
<li><img style="width: auto; height: 80px; margin: 10px; border-radius: 10px; border: 1px solid #d2d6de;" src="{{ asset('uploads/documents/' ~ image) | imagine_filter('avatar') }}"/></li>
{% endfor %}
我在网站上创建了一个文件夹。 媒体/缓存与CHMOD 777
但问题是没有生成图片! 你可以帮我这个吗?
如果我点击我网站上谷歌开发工具的图片,我注意到这样的路线:
<img style="width: auto; height: 80px; margin: 10px; border-radius: 10px; border: 1px solid #d2d6de;" src="https://test.hello.org/media/cache/resolve/avatar/uploads/documents/TEST-JEUDI.jpg">
答案 0 :(得分:0)
尝试这样做! https://sonata-project.org/bundles/media/master/doc/reference/extra.html
filter_sets:
cache: ~
avatar:
quality: 75
controller_action: 'SonataMediaBundle:Media:liipImagineFilter'
filters:
thumbnail: { size: [500, 70], mode: outbound }
“controller_action:'SonataMediaBundle:媒体:liipImagineFilter'//支付意向聘用”
我希望能帮到你