定制 mmelcor/yii2-imagehandler 二次开发

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

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

mmelcor/yii2-imagehandler

Composer 安装命令:

composer require mmelcor/yii2-imagehandler

包简介

A component to handle retriving multi-lingual images from an image repository.

README 文档

README

Yii2 Multi-language Image Handler

An extension designed to retrive images from an online Repository based on the currently selected application language.

Installation

The preferred method of installation is via composer.

Either run

php composer.phar require --prefer-dist mmelcor/yii2-imagehandler "*"

or add

"mmelcor\yii2-imagehander": "*"

to the require section of your composer.json file.

Usage

Once installed, use it in your application by adding the following to your components section in common\config\main.php (advanced) or config\web.php (basic template) :

'components' => [
	'[other components]',
	'imageHandler' => [
		'class' => 'mmelcor\imagehandler',
		'hostUrl' => '[your image repo base url]',
		'siteFolder' => '[base folder]',
		'defaultLang' => '[Language that will have all images]',
	],
],

In your controller either add the component to your init() by delcaring a protected variable and passing it as a parameter:

protected $iHandler;

public function init() {
	$this->iHandler = Yii::$app->imageHandler;
}
$this->parameters = [
	'iHandler' => $this->iHandler,
]:

or pass it to your views in the view action:

$iHandler = Yii::$app->imageHandler;

return $this->render('view', [
	'iHandler' => $iHandler,
]);

to call the specific image place the following in your view.

<img src="<?= $iHandler->getImage('/path/to/img') ?>" class="[classes]" alt="[image description]" />

This component works best with oorrwullie\yii2-babelfishfood.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固