定制 onadrog/imageconverterbundle 二次开发

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

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

onadrog/imageconverterbundle

Composer 安装命令:

composer require onadrog/imageconverterbundle

包简介

A simple FormType that convert images into WebP format

README 文档

README

Convert your images into WebP format using the symfony form Component and Doctrine bundle to persist data.

Requirements

Prod:

Installation:

composer require onadrog/imageconverterbundle
php bin/console asset:install

Minimal configuration

This package use php8 attributes.

Use ImageUpload and ImageUploadProperties attributes as follow.

// src/Entity/Foo.php
namespace App\Entity;

// ...
use Onadrog\ImageConverterBundle\Mapping\Attribute as Onadrog;

/**
 * @ORM\Entity(repositoryClass=FooRepository::class)
 */
#[Onadrog\ImageUpload]
class Foo
{
    // ...

    private $fileName;

    private $fileSlug;

    /**
     * @ORM\Column(type="json")
     */
    private ?array $fileDimension = [];

     /**
     * @ORM\Column(type="json")
     */
    private ?array $mimeTypes = [];

    private  $fileAlt;

    #[Onadrog\ImageUploadProperties(name: 'fileName', slug: 'fileSlug', alt: 'fileAlt', dimension: 'fileDimension', mimeTypes: 'mimeTypes')]
    private $file;
}

Once done use the ImageConverterType in your FormBuilder related to the property where the ImageUploadProperties is mapped (here file) .

// src/Form/FooType.php

namespace App\Foo\Form;

// ...
use Onadrog\ImageConverterBundle\Form\Type\ImageConverterType;

class FooType extends AbstractType
{
    //..
    public function builForm(FormBuilder $builder, array $options)
    {
        // ...

        $builder->add('file', ImageConverterType::class);
    }
}

Twig extension:

{% extends 'base.html.twig' %}

{% block body %}
    {{ image_converter_img(foo) }}
{% endblock %}

Configuration default values:

# config/packages/image_converter.yaml

image_converter:
  media_uploads_path: "%kernel.project_dir%/public/uploads/media/"
  namer: "default"
  quality: 80
  public_path: "/uploads/media/"
  remove_orphans: true
  keep_original: false
  use_js: false

Console commands:

onadrog:debug:config
onadrog:dump:config
onadrog:make:entity [options] <args>

For more informations read the Wiki

Donate:

Eth address: 0xB374931cc925042731d971C07708be68B115BC0d

Qr_code

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2021-09-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固