jwadin/imgix-bundle

将imgix库集成到Symfony 4+ & PHP 7.1+

维护者

详细信息

github.com/jwadin/ImgixBundle

源代码

安装: 10

依赖者: 0

建议者: 0

安全: 0

星星: 0

关注者: 0

分支: 3

类型:symfony-bundle

4.0.0 2019-07-05 06:25 UTC

README

将imgix库集成到Symfony中。

安装

通过使用Composer是安装此包的最佳方式。

对于Symfony 2.x运行

$ php composer.phar require tacticmedia/imgix-bundle ~1.0

对于Symfony 3.4+运行

$ php composer.phar require tacticmedia/imgix-bundle ~2.0

对于Symfony 4+运行

$ php composer.phar require tacticmedia/imgix-bundle ~3.0

对于使用PHP 7.1的Symfony 4+运行

$ php composer.phar require tacticmedia/imgix-bundle ^4.0

然后,启用该包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Tacticmedia\ImgixBundle\TacticmediaImgixBundle(),
    );
}

最后添加您的源

tacticmedia_imgix:
    enabled: true
    default_source: 'folder'
    sources:
        folder:
            domain: 'acme.imgix.net'
        proxy:
            domain: 'acme-proxy.imgix.net'
            sign_key: 'abcd1234'

使用方法

在您的Twig模板中只需这样做

<!-- Absolute URL with a web proxy source -->
<img src="{{ imgix('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png', source='proxy', width=200, height=166) }}" width="200" height="166"/>

<!-- Absolute path with a web folder source -->
<img src="{{ imgix('images/modules/logos_page/Octocat.png', w=200, h=166) }}" width="200" />

您应该在参数中将enableddomains[]设置中启用imgix以支持不同的环境。

许可证

此包以MIT许可证发布。请参阅包中的完整许可证。

Resources/meta/LICENSE

鸣谢

此存储库基于https://github.com/GoldenLine/ImgixBundle,该存储库似乎已被遗弃,并且未与Symfony的进展保持同步。