mindkomm / theme-lib-embed
优化WordPress主题中的嵌入。
1.0.0
2018-03-02 15:15 UTC
Requires
- php: >=7.0.0
This package is auto-updated.
Last update: 2024-09-05 05:48:31 UTC
README
优化WordPress主题中的嵌入。
- 允许您为oEmbed内容设置默认大小。
- 使用div标签包装oEmbed内容,以便更容易地为响应式设计进行样式设置。不过,您需要自己添加CSS。
- 优化可能缺少质量的预览图片的YouTube播放列表嵌入。
安装
您可以通过Composer安装此包。
composer require mindkomm/theme-lib-embed
用法
functions.php
$embeds = new Theme\Embed\Embed(); $embeds->init();
Embed构造函数接受两个参数
- $width
(int) oEmbed内容的默认宽度(以像素为单位)。默认为1400。 - $ratio
(float) 用于计算高度的比率。默认为16/9。
以下是一个示例,如果您希望oEmbed内容的宽度为800像素,高度为400像素。
$embeds = new Theme\Embed\Embed( 800, 0.5 ); $embeds->init();
如果您已经有了添加具有类responsive-embed
和keep-aspect-ratio
的div的embed_oembed_html
过滤器,您可能可以将其删除,因为此库也添加了一个。
支持
这是一个我们用于开发WordPress主题的包。您可以使用它,但目前我们不提供任何支持。