strapi-plugin-ckeditor icon indicating copy to clipboard operation
strapi-plugin-ckeditor copied to clipboard

Unable to add video from media library

Open sal1ner0 opened this issue 2 years ago • 6 comments

Hello, i'm not able to add any video from media library, and there is no error.

Nothing in console, nothing in log..

Do am i missing something? Have I forgotten some configuration or is it a bug?

Thanks

Strapi 4.5.2 strapi-plugin-ckeditor 1.1.2

sal1ner0 avatar Nov 29 '22 18:11 sal1ner0

I'm struggling with the same issue. I think it's just not supported.

Confuze avatar Jan 07 '23 15:01 Confuze

Hi! Inserting videos from the media library is not supported yet. For now, you can use the Media embed plugin.

Mgsy avatar Feb 01 '23 09:02 Mgsy

The same issue here. Thank you for providing this great plugin, we are waiting for good features like this one.

milad2golnia avatar Mar 14 '23 14:03 milad2golnia

Hi! Inserting videos from the media library is not supported yet. For now, you can use the Media embed plugin.

@Mgsy Today I found out that Media embed is just useful for some sources and when pasting an hosted video it raises this error "The media URL is not supported"

milad2golnia avatar Apr 10 '23 14:04 milad2golnia

any updates on this feature? @Mgsy

Arunjenson-ss avatar May 15 '24 16:05 Arunjenson-ss

I changed the admin/src/components/CKEditorInput/index.js and succeeded. Currently it works good enough for my use case:

  const handleChangeAssets = assets => {
    let assetsHtmlString = '';

    assets.map(asset => {
      const url = sanitize(asset.url);
      const alt = sanitize(asset.alt);

      if (asset.mime.includes('image')) {

        assetsHtmlString += `<img src="${url}" alt="${alt}" />`;
      } else {
        assetsHtmlString += `<a href="${url}" target="_blank">${alt} (${asset.mime})</a>`;
      }
    });

    const viewFragment = editorInstance.data.processor.toView(assetsHtmlString);

    const modelFragment = editorInstance.data.toModel(viewFragment);

    editorInstance.model.insertContent(modelFragment);

    handleToggleMediaLib();
  };

So I rendered the inserted video as a link. It can be improved with some preview library for example iframely or embedly.

https://github.com/user-attachments/assets/6cbf36b6-3dc6-463e-9ea4-7ee8566c8501

It's good enough for my use case as I don't need to preview it in the editor, I parsed the html (a href=a video src) in the front end and rendered it as video:

Image

Jeff-Tian avatar Dec 19 '24 03:12 Jeff-Tian