Search by

getolympus / olympus-dionysos-field-oembed

crewstyle

oEmbed field, this component is a part of the Olympus Dionysos fields.

Package info

github.com/GetOlympus/olympus-dionysos-field-oembed

Language:JavaScript

Type:olympus-field

pkg:composer/getolympus/olympus-dionysos-field-oembed

Statistics

Installs: 189

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v0.0.4 2023-12-18 19:08 UTC

This package is auto-updated.

Last update: 2026-09-21 05:30:20 UTC


README

Dionysos oEmbed Field

Olympus Component CodeFactor Grade Packagist Version MIT

This component is a part of the Olympus Dionysos fields for WordPress.

composer require getolympus/olympus-dionysos-field-oembed

Table of contents

Field initialization • Variables definition • Texts definition • Retrive data • Release history • Contributing

Field initialization

Use the following lines to add an oembed field in your WordPress admin pages or custom post type meta fields:

return \GetOlympus\Dionysos\Field\Oembed::build('my_oembed_field_id', [
    'title'       => 'Never gonna give you up!',
    'default'     => [
        'url'    => 'https://www.youtube.com/watch?v=Xxbd5keKhPU',
        'height' => 1000,
        'width'  => 916,
        'html'   => '<iframe title="Popopooooo" width="916" height="515" src="https://www.youtube.com/embed/Xxbd5keKhPU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>',
    ],
    'description' => 'You\'ve been Rick rolled!',

    /**
     * Texts definition
     * @see the `Texts definition` section below
     */
    't_addblock_label'    => 'Enter URL here.',
    't_removeblock_label' => 'Clear',
]);

Variables definition

Variable Type Default value if not set Accepted values
title String 'oEmbed' empty
default Array empty empty
description String empty empty

Texts definition

Code Default value Definition
t_addblock_label Enter URL here Used as an URL input placeholder
t_removeblock_label Clear Used as a Clear button area title

Retrive data

Retrieve your value from Database with a simple get_option('my_oembed_field_id', []) (see WordPress reference).
Below, a json_encode() example to understand how data are stored in Database:

{
  "url": "https://www.youtube.com/watch?v=Xxbd5keKhPU",
  "height": 1000,
  "width": 916,
  "html": "<iframe title=\"Popopooooo\" width=\"916\" height=\"515\" src=\"https://www.youtube.com/embed/Xxbd5keKhPU?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>"
}

And below, a simple example to show how to iterate on the data array in PHP:

// Get embed from Database
$embed = get_option('my_oembed_field_id', []);

// Check if embed is empty and display it
if (!empty($embed)) {
    echo stripcslashes($embed['html']);
}

Release history

Version Note
0.0.5 Fix jQuery integration on domReady
0.0.4 Fix JS ready
0.0.3 Better CSS display

Contributing

  1. Fork it (https://github.com/GetOlympus/olympus-dionysos-field-oembed/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Built with ♥ by Achraf Chouk ~ (c) since a long time.