PHPackages                             yii2mod/yii2-link-preview - 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. yii2mod/yii2-link-preview

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

yii2mod/yii2-link-preview
=========================

LinkPreview widget renders page preview

1.3(9y ago)281.7k11[1 issues](https://github.com/yii2mod/yii2-link-preview/issues)[1 PRs](https://github.com/yii2mod/yii2-link-preview/pulls)MITPHP

Since Jul 6Pushed 8y ago8 watchersCompare

[ Source](https://github.com/yii2mod/yii2-link-preview)[ Packagist](https://packagist.org/packages/yii2mod/yii2-link-preview)[ RSS](/packages/yii2mod-yii2-link-preview/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (4)Versions (9)Used By (0)

Yii2 Link Preview Widget
========================

[](#yii2-link-preview-widget)

LinkPreview widget automatically retrieves some information from the content of the link.

[![Latest Stable Version](https://camo.githubusercontent.com/ae98d57d3afd45df2014c13ca96ac7094f3e17dc1ab8a411abbd8fcea28e5d01/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d6c696e6b2d707265766965772f762f737461626c65)](https://packagist.org/packages/yii2mod/yii2-link-preview) [![Total Downloads](https://camo.githubusercontent.com/4a0022b7e049994ee39bc10afb6bc7bd91b333a19cd605b23bf3285f56453715/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d6c696e6b2d707265766965772f646f776e6c6f616473)](https://packagist.org/packages/yii2mod/yii2-link-preview) [![License](https://camo.githubusercontent.com/f276869185341624f0f8c0dfdb64e9cb9354cfb8b8ad630b3f263fb673b9a9a3/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d6c696e6b2d707265766965772f6c6963656e7365)](https://packagist.org/packages/yii2mod/yii2-link-preview)[![Build Status](https://camo.githubusercontent.com/7be29bba055bf6ce049a4d96805221162d3aa5905130c4018e72f22bd0cb8022/68747470733a2f2f7472617669732d63692e6f72672f796969326d6f642f796969322d6c696e6b2d707265766965772e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/yii2mod/yii2-link-preview)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist yii2mod/yii2-link-preview "*"

```

or add

```
"yii2mod/yii2-link-preview": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

1. Execute init migration:

```
php yii migrate/up --migrationPath=@vendor/yii2mod/yii2-link-preview/migrations
```

2. Define preview action in your controller:

```
public function actions()
{
    return [
        'link-preview' => LinkPreviewAction::className()
    ];
}
```

3. Add widget to your page as follows:

```
echo LinkPreview::widget([
    'selector' => '#your-input-id or .someclass',
    'clientOptions' => [
        'previewActionUrl' => \yii\helpers\Url::to(['link-preview'])
    ],
])
```

**Example of usage with the ActiveForm and saving the page info**

1. Create the basic form in the view:

```

        Preview
