tacticmedia/imgix-bundle

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

安装数: 2,772

依赖项: 0

建议者: 0

安全: 0

星级: 4

关注者: 1

分支: 3

类型:symfony-bundle

4.0.0 2019-07-05 06:25 UTC

This package is auto-updated.

Last update: 2024-09-05 17:42:31 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 进步保持同步。