2017 © Pedro Peláez
 

yii2-extension widget-imagex

Adding opengraph meta tags and microdata markdown to images

image

zyx/widget-imagex

Adding opengraph meta tags and microdata markdown to images

  • Thursday, June 26, 2014
  • by zyx
  • Repository
  • 2 Watchers
  • 1 Stars
  • 45 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

ImageX

Latest Stable Version Latest Unstable Version Total Downloads License Code Climate Scrutinizer Code Quality, (*1)

Widget for simple generating OpenGraph meta tags and Schema.org markdown for images ('X' stands for 'eXtended')., (*2)

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())., (*3)

REQUIREMENTS

You should generally follow Yii 2 requirements. The minimum is that your Web server supports PHP 5.4.0., (*4)

INSTALLATION

Install via Composer

If you do not have Composer, you may install it by following the instructions at getcomposer.org., (*5)

Either run, (*6)

php composer.phar require --prefer-dist zyx/widget-imagex "*"

or add, (*7)

"zyx/widget-imagex": "*"

to the require section of your composer.json., (*8)

USAGE

Just add following string to your layout, (*9)

use zyx\widgets\ImageX;

And call widget where the image is supposed to be instead of usual Html::img():, (*10)

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]., (*11)

So, the result of example above should be something like this:

In the HEAD:, (*12)

...
  <meta property="og:image" content="http://static.yiiframework.com/css/img/logo.png">
  <meta property="og:image:type" content="image/png">
  <meta property="og:image:width" content="280">
  <meta property="og:image:height" content="60">
...

In the BODY ('img' is wrapped in 'div' tag):, (*13)

...


...

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., (*14)

So you can just call:, (*15)

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., (*16)

The Versions

26/06 2014

dev-master

9999999-dev

Adding opengraph meta tags and microdata markdown to images

  Sources   Download

BSD-3-Clause

The Requires

 

by Serge Postrash aka SDKiller

image images opengraph schema.org microdata

07/05 2014

0.8.1

0.8.1.0

Adding opengraph meta tags and microdata markdown to images

  Sources   Download

BSD-3-Clause

The Requires

 

by Serge Postrash aka SDKiller

image images opengraph schema.org microdata

07/05 2014

0.8.0

0.8.0.0

Adding opengraph meta tags and microdata markdown to images

  Sources   Download

BSD-3-Clause

The Requires

 

by Serge Postrash aka SDKiller

image images opengraph schema.org microdata