LinkPreview widget automatically retrieves some information from the content of the link.
The preferred way to install this extension is through composer.
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.
- Execute init migration:
php yii migrate/up --migrationPath=@vendor/yii2mod/yii2-link-preview/migrations
- Define preview action in your controller:
public function actions()
{
return [
'link-preview' => LinkPreviewAction::className()
];
}
- Add widget to your page as follows:
echo LinkPreview::widget([
'selector' => '#your-input-id or .someclass',
'clientOptions' => [
'previewActionUrl' => \yii\helpers\Url::to(['link-preview'])
],
])