承接 zeglup/media-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

zeglup/media-bundle

Composer 安装命令:

composer require zeglup/media-bundle

包简介

Fork from Donjohn/MediaBundle, a simple media bundle inspired by sonata media bundle

README 文档

README

SensioLabsInsight

Give credits to Sonata, they inspired this bundle.

Installation

Composer

composer require donjohn/media-bundle

Minimal configuration

Create a new class and extends it with Donjohn\MediaBundle\Media

namespace YourBundle\Entity;
use Donjohn\MediaBundle\Model\Media as BaseMedia;

/**
 * @ORM\Table()
 * @ORM\Entity()
 */
class YourMedia extends BaseMedia
{
    /**
     * @var integer
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="IDENTITY")
    */
    protected $id;
}

LiipImagineBundle

Add this to your config.yml

liip_imagine:
    filter_sets:
        full: 
            quality: 100
        thumbnail:
            quality: 75
            filters:
                auto_rotate: ~
                thumbnail: { size: [120, 120], mode: outbound }

See LiipImagineBundle Configuration for liip filters configuration

Optional configuration

Change folder for uploaded files

donjohn_media:
    upload_folder: /AnotherFolder

liip_imagine:
    resolvers:
        default:
            web_path:
                cache_prefix: AnotherFolder/cache

Restrict uploaded file size

donjohn_media:
    file_max_size: 500M

Providers

Available providers :

  • image
  • file

Usage

To insert a media in the twig, use the block with an optional filter name, defined in the liip_imagine.filter_sets section. If you don't provider a filter name, 'reference' filter is default. it will return the original media uploaded with any filter or post processing.

{% media mediaObject, '<filter>' %}

You can also pass class/width/height/alt options to the media rendering:

{% media mediaObject, '<filter>' with {class: 'classwanted class2wanted', alt: 'title', width: '200px', height: '50px'} %}

FormType

An Donjohn\MediaBundle\Form\Type\MediaType is available

$builder->add(<fieldName>, MediaType::class, ['media_class'=> YourEntity::class] );

provider option default value is null. A guesser will try on the fly to detect the best provider fo each file unless you define the option. The default guess is 'file'.

Set 'allow_delete' option to false if you don't want to allow removing media from an entity. It removes the unlink checkbox in the form.

Set 'create_on_update' option to true if you don't want to update the current media when uploading a file but rather create a new media instead. Old one is not removed.

If you want to upload a collection of Medias set multiple to true.

$builder->add(<fieldName>, MediaType::class, ['media_class' => YourEntity::class, 'multiple' => true ] );

OneupUploader

For very large files, the bundle includes the Fine Uploader feature thanks to OneUpUploaderBundle.

$builder->add(<fieldName>, MediaType::class, , ['media_class' => YourEntity::class, 'fine_uploader' => true, 'multiple' => <true|false> ] );

Don't forget to install fineuploader (bower/npm/...) and include the css/js in your layout (fix path if needed).

Add the OneupUploaderBundle to your AppKernel.php

    new Oneup\UploaderBundle\OneupUploaderBundle(),

And to config.yml, add:

# Read the documentation: https://github.com/1up-lab/OneupUploaderBundle/blob/master/Resources/doc/index.md
oneup_uploader:
    chunks:
        storage:
            directory: "%kernel.cache_dir%/uploader/chunks"
    mappings:
        donjohn_media:
            namer: Donjohn\MediaBundle\Uploader\Naming\OriginalNamer
            use_orphanage: true
            frontend: fineuploader

You can change the uploaded chunk size or the template used to render the fineuploader frame

donjohn_media:
    chunk_size: 50M #default
    fine_uploader_template: YourFineUploaderTempalte.twig.html

Custom MediaProvider

To implement your own provider, extends the BaseProvider and redefine abstract function.
Autowiring should do the job...

Api platform

The bundle is compatible with APIPlatform.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固