{"id":14966783,"url":"https://github.com/yii2mod/yii2-link-preview","last_synced_at":"2025-10-25T17:30:42.531Z","repository":{"id":34485672,"uuid":"38425123","full_name":"yii2mod/yii2-link-preview","owner":"yii2mod","description":"LinkPreview widget render page preview","archived":false,"fork":false,"pushed_at":"2018-05-03T08:13:30.000Z","size":36,"stargazers_count":28,"open_issues_count":2,"forks_count":12,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-01-31T09:34:11.141Z","etag":null,"topics":["yii2","yii2-extension","yii2-link-preview","yii2-page-preview"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yii2mod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-02T09:58:23.000Z","updated_at":"2024-09-04T16:14:46.000Z","dependencies_parsed_at":"2022-09-14T10:11:02.682Z","dependency_job_id":null,"html_url":"https://github.com/yii2mod/yii2-link-preview","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2mod%2Fyii2-link-preview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2mod%2Fyii2-link-preview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2mod%2Fyii2-link-preview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2mod%2Fyii2-link-preview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yii2mod","download_url":"https://codeload.github.com/yii2mod/yii2-link-preview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238183702,"owners_count":19430172,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["yii2","yii2-extension","yii2-link-preview","yii2-page-preview"],"created_at":"2024-09-24T13:36:56.331Z","updated_at":"2025-10-25T17:30:37.168Z","avatar_url":"https://github.com/yii2mod.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Yii2 Link Preview Widget\n===========\n\nLinkPreview widget automatically retrieves some information from the content of the link.\n\n[![Latest Stable Version](https://poser.pugx.org/yii2mod/yii2-link-preview/v/stable)](https://packagist.org/packages/yii2mod/yii2-link-preview) [![Total Downloads](https://poser.pugx.org/yii2mod/yii2-link-preview/downloads)](https://packagist.org/packages/yii2mod/yii2-link-preview) [![License](https://poser.pugx.org/yii2mod/yii2-link-preview/license)](https://packagist.org/packages/yii2mod/yii2-link-preview)\n[![Build Status](https://travis-ci.org/yii2mod/yii2-link-preview.svg?branch=master)](https://travis-ci.org/yii2mod/yii2-link-preview)\n\nInstallation \n------------\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\nphp composer.phar require --prefer-dist yii2mod/yii2-link-preview \"*\"\n```\n\nor add\n\n```\n\"yii2mod/yii2-link-preview\": \"*\"\n```\n\nto the require section of your `composer.json` file.\n\n\nUsage\n-----\n1) Execute init migration:\n```php\nphp yii migrate/up --migrationPath=@vendor/yii2mod/yii2-link-preview/migrations\n```    \n\n2) Define preview action in your controller:\n```php\npublic function actions()\n{\n    return [\n        'link-preview' =\u003e LinkPreviewAction::className()\n    ];\n}\n```     \n \n3) Add widget to your page as follows:\n```php\necho LinkPreview::widget([\n    'selector' =\u003e '#your-input-id or .someclass',\n    'clientOptions' =\u003e [\n        'previewActionUrl' =\u003e \\yii\\helpers\\Url::to(['link-preview'])\n    ],\n])\n``` \n**Example of usage with the ActiveForm and saving the page info**\n\n1) Create the basic form in the view:\n```php\n\u003c?php $form = \\yii\\widgets\\ActiveForm::begin() ?\u003e\n    \u003cdiv class=\"form-group\"\u003e\n        \u003clabel for=\"preview\"\u003ePreview\u003c/label\u003e\n        \u003cinput name=\"preview\" class=\"form-control\" id=\"preview\" placeholder=\"Preview\"\u003e\n    \u003c/div\u003e\n    \u003c?php echo \\yii2mod\\linkpreview\\LinkPreview::widget([\n        'selector' =\u003e '#preview',\n        'clientOptions' =\u003e [\n            'previewActionUrl' =\u003e \\yii\\helpers\\Url::to(['link-preview'])\n        ],\n    ]) ?\u003e\n    \u003cdiv class=\"form-group\"\u003e\n        \u003c?= \\yii\\helpers\\Html::submitButton('Save', ['class' =\u003e 'btn btn-primary']) ?\u003e\n    \u003c/div\u003e\n\u003c?php \\yii\\widgets\\ActiveForm::end() ?\u003e\n```\n\n2) Add the following code to your action for the saving page info:\n```php\n$model = new LinkPreviewModel();\nif ($model-\u003eload(Yii::$app-\u003erequest-\u003epost()) \u0026\u0026 $model-\u003evalidate()) {\n    $model-\u003esave();\n}\n\n// or the short version \n\n$linkPreviewId = LinkPreviewModel::saveAndGetId(Yii::$app-\u003erequest-\u003epost());\n\n```\n\n#### GitHub Preview Example\n-----\n![Alt text](http://res.cloudinary.com/zfort/image/upload/v1436190465/Preview.png \"GitHub Preview Example\")\n\n#### Video Link Preview Example\n-----\n![Alt text](http://res.cloudinary.com/zfort/image/upload/v1463675454/Youtube%20link%20preview.png \"Video Link Preview Example\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyii2mod%2Fyii2-link-preview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyii2mod%2Fyii2-link-preview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyii2mod%2Fyii2-link-preview/lists"}