PHPackages                             mmelcor/yii2-imagehandler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mmelcor/yii2-imagehandler

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

mmelcor/yii2-imagehandler
=========================

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

0.6(9y ago)2381MITPHP

Since Feb 15Pushed 9y ago2 watchersCompare

[ Source](https://github.com/mmelcor/yii2-imagehandler)[ Packagist](https://packagist.org/packages/mmelcor/yii2-imagehandler)[ RSS](/packages/mmelcor-yii2-imagehandler/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (1)Versions (10)Used By (1)

yii2-imagehandler
=================

[](#yii2-imagehandler)

Yii2 Multi-language Image Handler
=================================

[](#yii2-multi-language-image-handler)

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

Installation
------------

[](#installation)

The preferred method of installation is via [composer](http://getcomposer.org/download/).

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
-----

[](#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.

```
