makeitbetter/yiiimages 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

makeitbetter/yiiimages

Composer 安装命令:

composer require makeitbetter/yiiimages

包简介

Images manager module for Yii2.

README 文档

README

N|Solid

Yiiimages is an images manager for Yii framework 2.0. It stores the files in a separate directory. In models images are saved as paths to files relative to this directory. When images is published their thumbnails are created in an accessible via HTTP location.

Installation

Add package:

#!sh
$ composer require makeitbetter/yiiimages

Configure the application by adding (yii2 guide):

#!php
$config['modules']['yiiimages'] = [
    'class' => 'makeitbetter\yiiimages\Module',
    'options' => [],
];
$config['bootstrap'][] = 'yiiimages';

Available options:

  • sourceFolder - Path to folder where the images will be stored. Default: @app/media.
  • targetFolder - Path relative to web root where the thumbnails will be putted. Default: thumbnails
  • paddingColor - Hexadecimal RGB color to fill thumbnails padding. Default: white, ffffff.
  • getThumbnailPathMethod - Function to create thumbnail items path. It should takes Thumbnail object and returns string. By default class's self method will be applied.
  • maxUploadNumber - Max number of images available to be uploaded at one time.

Next options define parameters for create thumbnails in the manager page (see more in the description of Class Thumbnail ):

  • width - Default: 150.
  • height - Default: 150.
  • crop - Default: true.
  • stretch - Default: false.

Finally, distribute permissions. They should be named: browseImages, addImages, deleteImages.

See more about an authorization in yii2 guide

Usage

In you forms:

#!php
use makeitbetter\yiiimages\widgets\ImageInput;
use yii\widgets\ActiveForm;

$form = ActiveForm::begin();

echo $form->field($model, 'property_name')->widget(ImageInput::className(), $options);

ActiveForm::end();

Or without an ActiveForm object:

#!php
echo ImageInput::widget(['model' => $model, 'attribute' => 'property_name']);

Displaying images:

#!php
use makeitbetter\thumbnail\Thumbnail;

echo Thumbnail::of($model->propery_name, 150, 150)->img()

See more about using a Thumbnail helper in the description of class.

Internationalisation

For adding translations of module strings register a source modules/yiiimages. For example add to your application config file following code:

#!php
$config['components']['i18n'] = [
    'translations' => [
        ...
        'modules*' => [
            'class' => 'yii\i18n\PhpMessageSource',
        ],
    ],
];

This configuration means that the application will search the translations at file @app/messages/xx-XX/modules/yiiimages.php

See more about internationalisation in yii2 guide

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2017-07-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固