Nova Ckeditor
  • 🏁Getting Started
    • Introduction
    • Installation
    • Support Us
    • License
    • Demo
  • 🚀Basic Usage
    • Usage
    • Notes
  • ⚙️Advanced Usage
    • Customize ImageStorage
    • Integrating NovaFileArtisan (Larupload) with Image Resource
    • Customize AudioStorage
    • Customize FileStorage
    • Multiple Toolbars
    • Customize Toolbar Items
    • Media Embed
    • CkEditor Field Options
      • Toolbar
      • Height
      • Limit On Index
      • Content Language
      • Force Paste as Plain Text
      • Alert Before Unsaved Changes
      • Text Part Language
      • General HTML Support
      • Group Items In Overflow Mode
      • Image Browser
      • Audio Browser
      • Video Browser
      • File Browser
      • Snippets
    • Configuration
      • Video Model
      • Image Model
      • Memory
      • Max Image Quality
      • Image Max Width
      • Image Max Height
      • Image Naming Method
      • Image Processing Library
      • Audio Naming Method
      • File Naming Method
      • Toolbars
        • Default Toolbar
        • Toolbar 1
          • Height
          • Items
          • Options
          • Content Lang
          • Force Paste as Plain Text
          • Alert Before Unsaved Changes
          • UI Language
            • UI Language Name
            • UI Language Script
          • Text Part Language
          • General HTML Support
          • Group Items In Overflow Mode
          • Image Browser
          • Audio Browser
          • Video Browser
          • File Browser
          • Insert Image Types
          • Insert Image Size
          • Snippets
  • ⚪Other
    • Migration
    • Credit and Thanks
Powered by GitBook
On this page
Edit on GitHub
  1. Advanced Usage

Media Embed

PreviousCustomize Toolbar ItemsNextCkEditor Field Options

Last updated 1 year ago

The feature adds support for easily inserting embeddable media, such as YouTube or Vimeo videos and tweets, into your rich text content.

  • To embed media, you can utilize the Insert media button available in the toolbar.

  • Alternatively, you can directly paste the media URL into the editor content, and it will be automatically embedded for you.

Configuration:

To configure the media embed feature, you have the option to override providers or add extraProviders through the configuration file.

config/nova-ckeditor.php
<?php

return [
    ...
    'toolbar' => [
        ...

        'options' => [
            ...

            'mediaEmbed' => [
                'providers' => [
                    [
                        'name' => 'youtube',
                        'url'  => [
                            '/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)(?:&t=(\d+))?/',
                            '/^(?:m\.)?youtube\.com\/v\/([\w-]+)(?:\?t=(\d+))?/',
                            '/^youtube\.com\/embed\/([\w-]+)(?:\?start=(\d+))?/',
                            '/^youtu\.be\/([\w-]+)(?:\?t=(\d+))?/'
                        ],
                        'html' => '
                            <div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: calc(56.2493% + 26px);">
                                <div><b>id</b>: ${match[1]}, <b>start</b>: ${match[2]}</div>
                                <iframe
                                    src="https://www.youtube.com/embed/${match[1]}${match[2] ? `?start=${match[2]}` : ""}"
                                    style="position: absolute; width: 100%; height: calc(100% - 26px); top: 26px; left: 0;"
                                    frameborder="0"
                                    allow="autoplay; encrypted-media"
                                    allowfullscreen
                                />
                            </div>'
                    ]
                ],
                
                // or
                'extraProviders' => [
                    [
                        'name' => 'example',
                        'url'  => '/^example\.com\/media\/(\w+)\/(.+)/',
                        'html' => '<p>first: ${match[1]}</p><p>second: ${match[2]}</p>'
                    ]
                ]
            ],
        ]
    ],
];

For more detailed information and instructions on configuring media embed, please refer to the official documentation:

⚙️
Media Embed Documentation
media embed