Skip to content

Commit

Permalink
EWPP-1300: Using the OE OEmbed component.
Browse files Browse the repository at this point in the history
  • Loading branch information
upchuk committed Aug 6, 2021
1 parent ccb7109 commit 0893d47
Show file tree
Hide file tree
Showing 38 changed files with 126 additions and 2,849 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"openeuropa/task-runner-drupal-project-symlink": "^1.0",
"openeuropa/oe_link_lists": "dev-master",
"openeuropa/oe_webtools": "dev-master",
"openeuropa/oe_oembed": "dev-EPIC-EWPP-1294-Embed",
"drupal/drupal-extension": "~4.0",
"phpunit/phpunit": "^7 || ^8",
"nikic/php-parser": "^3.1.5",
Expand Down
58 changes: 6 additions & 52 deletions modules/oe_media_embed/README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,15 @@
# OpenEuropa Media Embed module

The OpenEuropa Media Embed module allows the embedding of Media entities into content in an agnostic (non-Drupal) way.
The OpenEuropa Media Embed module integrates with OE OEmbed to provide a Media-based embed button.

To this end, it comes with two main elements: the WYSIWYG embed button and the filter plugin. On top of that, it allows
the site administrators to define which available view displays are also available to be embedded.
This module serves as a BC legacy bridge between the old media-based embed button and the new
generic one that has been moved to OE OEmbed.

## WYSIWYG button
# Dependencies

Using the media embed WYSIWYG button, editors can select media entities that they wish to embed. Upon selecting the media entity, an oEmbed-based embed code is
inserted in the content. This code follows the oEmbed protocol and is therefore understandable by other clients as well. An example embed code:
This module depends on the OE OEmbed module so make sure you add it to your composer.json:

```
<p data-oembed="https://oembed.ec.europa.eu?url=https%3A//data.ec.europa.eu/ewp/media/118a06e9-e7df-4b7b-8ab2-5f5addc2f0b3">
<a href="https://data.ec.europa.eu/ewp/media/118a06e9-e7df-4b7b-8ab2-5f5addc2f0b3">sdasd</a>
</p>
composer require openeuropa/oe_oembed
```

Where `118a06e9-e7df-4b7b-8ab2-5f5addc2f0b3` is the UUID of the media entity.


Moreover, we have the [OpenEuropa oEmbed component][1] which will be used when a site expects its content to be read by external systems that
need to understand the embed codes. Essentially, it acts as an oEmbed provider for the media resources on the site.

## Text filter

The embed code provided by the WYSIWYG button is transformed into the rendered entity by the filter plugin `FilterMediaEmbed`.
Adding this to a text format will replace the embed tags with the rendered media entity.


## Embeddable view displays

Site administrators will need to define which available view modes are also available to be embedded via the tools described above.
This is done by selecting the available view displays on the display mode configuration page for each available media bundle.

## Usage

In order to use the functionalities of the module, follow the next steps:

1) Create a text format.
You can do so by navigating to `/admin/config/content/formats` and clicking the "Add text format button". More information
is available on the official [documentation][2].

2) Add the Media Embed button to your Active toolbar.
You can do that while creating your text format or by navigating to the text format configuration form (`/admin/config/content/formats/manage/TEXT_FORMAT_ID`).
Make sure you select CKEditor as the Text editor for your text format and move the "Media" button from the *available buttons* section to the Active toolbar.

3) Enable the "Embeds media entities using the oEmbed format" filter.
This filter needs to be enabled and placed last in the Filter processing order.
(**WARNING**: This is very important if you want the oEmbed specific urls to be converted into internal aliases)

4) Make view displays embeddable.
Once the previous steps are done, navigate to the display mode configuration of the bundle you wish to be embeddable and select which of
the available view displays will be available for embedding. E.g., in order to configure which of the view displays of the Image media type
are available for embedding, you will need to navigate to `/admin/structure/media/manage/image/display`.



[1]: https://github.com/openeuropa/oe_oembed
[2]: https://www.drupal.org/docs/user_guide/en/structure-text-format-config.html

6 changes: 3 additions & 3 deletions modules/oe_media_embed/config/install/embed.button.media.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ dependencies:
- oe_media_embed
label: Media
id: media
type_id: embed_media
type_id: oe_oembed_entities
type_settings:
media_types:
entity_type: media
bundles:
av_portal_photo: av_portal_photo
av_portal_video: av_portal_video
document: document
Expand All @@ -16,4 +17,3 @@ type_settings:
entity_browser: ''
entity_browser_settings:
display_review: false
icon_uuid: null

This file was deleted.

39 changes: 0 additions & 39 deletions modules/oe_media_embed/config/schema/oe_media_embed.schema.yml

This file was deleted.

8 changes: 0 additions & 8 deletions modules/oe_media_embed/css/ckeditor_embed.css

This file was deleted.

30 changes: 0 additions & 30 deletions modules/oe_media_embed/css/oe_media_embed.dialog.css

This file was deleted.

File renamed without changes
59 changes: 0 additions & 59 deletions modules/oe_media_embed/js/oe_media_embed.dialog.js

This file was deleted.

125 changes: 0 additions & 125 deletions modules/oe_media_embed/js/plugins/embed_media/plugin.js

This file was deleted.

1 change: 1 addition & 0 deletions modules/oe_media_embed/oe_media_embed.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dependencies:
- media_avportal:media_avportal
- embed:embed
- drupal:ckeditor
- oe_oembed:oe_oembed
26 changes: 26 additions & 0 deletions modules/oe_media_embed/oe_media_embed.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* @file
* Install functions for OpenEuropa Media Embed module.
*/

declare(strict_types = 1);

use Drupal\embed\Entity\EmbedButton;

/**
* Implements hook_install().
*/
function oe_media_embed_install($is_syncing) {
if ($is_syncing) {
return;
}

// Set the icon onto the shipped embed button.
/** @var \Drupal\embed\EmbedButtonInterface $button */
$button = EmbedButton::load('media');
$icon = EmbedButton::convertImageToEncodedData(drupal_get_path('module', 'oe_media_embed') . '/embed.png');
$button->set('icon', $icon);
$button->save();
}
Loading

0 comments on commit 0893d47

Please sign in to comment.