定制 arsthanea/remote-media-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

arsthanea/remote-media-bundle

Composer 安装命令:

composer require arsthanea/remote-media-bundle

包简介

README 文档

README

This bundle enables you to store your assets in S3 bucket instead of local filesystem

Installation

composer require arsthanea/remote-media-bundle

Configuration

Add this bundle to your kernel after the KunstmaanMediaBundle:

…
  $bundles = [
    //
      new Kunstmaan\MediaBundle\KunstmaanMediaBundle(),
      new ArsThanea\RemoteMediaBundle\RemoteMediaBundle(),
    //
  ];
…

Setup S3 details in config.yml:

remote_media:
  cdn:
    # The public URL to your bucket. You may use a CDN for instance
    # If not sure leave null
    #
    media_url: https://a-cdn-for-my-bucket.cloudflare.net
    
    # cached thumbnails can be stored in a prefixed path.
    # the default value is the env name (i.e. "dev/") or no prefix on production
    #
    # cache_prefix: dev
    
    # To speed up cache resolution, provide a doctrine_cache provider:
    #
    # cache_provider: liip_imagine

    s3:
      bucket: acme-bundle
      
      # this is optional and defaults to eu-west-1
      #
      # region: eu-west-1
      
      # please provide AWS access key and secret for this bucket:
      #
      access_key: %aws_access_key%
      access_secret: %aws_access_secret%

You need to tweak the liip_imagine configuration a bit. Locate the default settings in config.yml or other place and set the cache and data_provider keys to remote_media value:

liip_imagine:
  cache: remote_media
  data_loader: remote_media

Setup cache provider

Use DoctrineCacheBundle (already used by Kunstmaan Bundles) to create a cache provider:

doctrine_cache:
  providers:
    liip_imagine:
      type: redis

Usage

Use media_url twig function to replace the media path with a CDN host. If you don’t need the CDN please keep in mind that Media::getUrl() now returns a full URL instead of just a relative path.

  <img src="{{ media_url(resource.image.url) }}">

统计信息

  • 总下载量: 9.58k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固