https://github.com/sdkiller/zyx-widget-imagex
OpenGraph meta tags and Schema.org markdown for images
https://github.com/sdkiller/zyx-widget-imagex
Last synced: 11 days ago
JSON representation
OpenGraph meta tags and Schema.org markdown for images
- Host: GitHub
- URL: https://github.com/sdkiller/zyx-widget-imagex
- Owner: SDKiller
- License: other
- Created: 2014-05-07T10:08:53.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-06-26T01:16:48.000Z (almost 11 years ago)
- Last Synced: 2025-02-16T20:19:26.309Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 185 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
ImageX
=======[](https://packagist.org/packages/zyx/widget-imagex)
[](https://packagist.org/packages/zyx/widget-imagex)
[](https://packagist.org/packages/zyx/widget-imagex)
[](https://packagist.org/packages/zyx/widget-imagex)
[](https://codeclimate.com/github/SDKiller/zyx-widget-imagex)
[](https://scrutinizer-ci.com/g/SDKiller/zyx-widget-imagex/)Widget for simple generating OpenGraph meta tags and Schema.org markdown for images
_('X' stands for 'eXtended')_.You may do absolutely nothing - OpenGraph meta tags and Schema.org markdown will be generated 'on-the-fly' from image properties (which you can still define like you do in ```Html::img()```).
REQUIREMENTS
------------You should generally follow [Yii 2 requirements](https://github.com/yiisoft/yii2/blob/master/README.md).
The minimum is that your Web server supports PHP 5.4.0.INSTALLATION
------------### Install via Composer
If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions
at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix).Either run
```
php composer.phar require --prefer-dist zyx/widget-imagex "*"
```or add
```
"zyx/widget-imagex": "*"
```to the require section of your composer.json.
USAGE
-----Just add following string to your layout
```
use zyx\widgets\ImageX;
```And call widget where the image is supposed to be instead of usual ```Html::img()```:
```
echo ImageX::widget([
'src' => 'http://static.yiiframework.com/css/img/logo.png',
'options' => ['width' => 280, 'height' => 60],
'og' => [],
'md' => ['div_class' => 'image_wrap']
]);```
**Note:** only 'src' parameter is mandatory. Array of 'options' is the same you use for image options in ```Html::img()```. If both 'og' (OpenGraph) and 'md' (schema.org) configuration arrays are empty - you may not declare them at all. You can to disable one of them (they are both enabled by default) - e.g. ```'md' => ['enable' => false]```.
So, the result of example above should be something like this:
--------------------------------------------------------------In the HEAD:
```
...
...```
In the BODY ('img' is wrapped in 'div' tag):
```
...
![]()
...```
Properties like 'width' and 'height' set explicitly in 'og' and 'md' configuration arrays, passed to widget, have priority.
If no such options were set, widget attempts to extract properties from image 'options' array.So you can just call:
```
echo ImageX::widget([
'src' => 'http://static.yiiframework.com/css/img/logo.png',
'options' => ['width' => 280, 'height' => 60]
]);```
like you called ```Html::img()``` with no additional options.