first-image
所属分类:内容生成
开发工具:PHP
文件大小:24KB
下载次数:0
上传日期:2022-12-29 12:40:36
上 传 者:
sh-1993
说明: 一个Craft 3插件,用于从编校器字段获取第一个图像。
(A Craft 3 Plugin to get first image from a redactor field.)
文件列表:
.craftplugin (554, 2022-12-29)
CHANGELOG.md (362, 2022-12-29)
LICENSE (1068, 2022-12-29)
LICENSE.md (1080, 2022-12-29)
composer.json (1059, 2022-12-29)
src (0, 2022-12-29)
src\FirstImage.php (1762, 2022-12-29)
src\icon-mask.svg (1825, 2022-12-29)
src\icon.svg (1825, 2022-12-29)
src\libs (0, 2022-12-29)
src\libs\HtmlDomParser.php (467, 2022-12-29)
src\libs\simplehtmldom_1_9_1 (0, 2022-12-29)
src\libs\simplehtmldom_1_9_1\simple_html_dom.php (59254, 2022-12-29)
src\translations (0, 2022-12-29)
src\translations\en (0, 2022-12-29)
src\translations\en\first-image.php (357, 2022-12-29)
src\twigextensions (0, 2022-12-29)
src\twigextensions\FirstImageTwigExtension.php (1467, 2022-12-29)
# First Image plugin for Craft CMS 3.x
A plugin to get first image from Redactor Field.
## Requirements
This plugin requires Craft CMS 3.0.0 or later.
## Installation
To install the plugin, follow these instructions.
1. Open your terminal and go to your Craft project:
cd /path/to/project
2. Then tell Composer to load the plugin:
composer require by/first-image
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for First Image.
## Using First Image
There are two ways of getting first image from a redactor field:
{{ entry.body | getFirstImage }}
or
{% set image = getFirstImage(entry.body) %}
This will output the source of the first image found, which then can be used in `
` tag.
Brought to you by [Bhashkar Yadav](https://360adaptive.com)
近期下载者:
相关文件:
收藏者: