mindkomm/theme-lib-embed

Optimizes embeds in WordPress themes.

1.0.0 2018-03-02 15:15 UTC

This package is auto-updated.

Last update: 2024-12-05 06:15:53 UTC


README

Optimizes embeds in WordPress themes.

  • Allows you to set default sizes for oEmbed contents.
  • Wraps oEmbed content with div tags to easier style them for responsiveness. You need to add the CSS yourself, though.
  • Optimizes Youtube playlist embeds where the preview image might lack in quality.

Installation

You can install the package via Composer:

composer require mindkomm/theme-lib-embed

Usage

functions.php

$embeds = new Theme\Embed\Embed();
$embeds->init();

The Embed constructor takes two parameters:

  • $width
    (int) The default width for oEmbed content in pixels. Default 1400.
  • $ratio
    (float) The ratio to use to calculate the height. Default 16/9.

Here’s an example if you wanted your oEmbed contents to have a width of 800px and a height of 400px.

$embeds = new Theme\Embed\Embed( 800, 0.5 );
$embeds->init();

If you already have an embed_oembed_html filter in place that adds divs with classes responsive-embed and keep-aspect-ratio, you could probably remove it, because this library already adds one, too.

Support

This is a package that we use at MIND to develop WordPress themes. You’re free to use it, but currently, we don’t provide any support.