承接 rankletter/commonmark-ext-seo-image 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rankletter/commonmark-ext-seo-image

Composer 安装命令:

composer require rankletter/commonmark-ext-seo-image

包简介

Adds support for explicit width and height as well as lazy loading to the league/commonmark markdown parser package

README 文档

README

🚧️ This extension is work in progress. Until 1.0 is release breaking changes might happen. Use with caution.

Tests

This image extension for league/commonmark adds:

  • the lazy loading attribute as well as
  • explicit height and width attributes to keep the layout shifts to a minimum. This works for both absolute URLs and local images.

The package is largely based on simonvomeyser/commonmark-ext-lazy-image! It is licensed under the same MIT license.

Install

composer require rankletter/commonmark-ext-seo-image

Example

Assuming /path/to/image.jpg points to an image with a size of 1024x512 pixels, the following example

use League\CommonMark\Environment;
use RankLetter\CommonMarkImageExtension\SEOImageExtension;

$this->environment = Environment::createCommonMarkEnvironment();
$this->environment->addExtension(new SEOImageExtension);

$converter = new CommonMarkConverter([], $this->environment);
$html = $converter->convertToHtml('![alt text](/path/to/image.jpg)');

This creates the following HTML

<img src="/path/to/image.jpg" alt="alt text" loading="lazy" width="1024" height="512" />

Further Options

Further options to replicate the lazy loading using JavaScript packages are supported. For more details please check the original package. This functionality will remain for now.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固