Jump to content

Customize WYSIWYG editor for URL override to embed object


MrFisc

Recommended Posts

I'm looking for a way to add custom embedded content when you paste a link matching specific criteria into the WYSIWYG editor. 

Similar to how when you paste a YouTube URL it turns it into an embedded video, or how when you paste a forum thread's URL, it converts it into the embedded version thereof. But I want to make a plugin that does it with a custom URL / embed code.

Link to comment
Share on other sites

24 minutes ago, Nathan Explosion said:

You need to override oembedServices() in \IPS\Parser\Text to add your domain/endpoint to the existing list of domains/endpoints (which I do in https://invisioncommunity.com/contributors/files/8963-ne-oembedservices-management/)

....and then your endpoint needs to output the code, which is then returned to the editor for display.

Unfortunately, I'm unable to see that page (not sure why).

To do this, would I need to make a Hook for `\IPS\Parsers\Text`? Or do I create a subclass of it and register it somewhere? Where do I place my "endpoint"?

Link to comment
Share on other sites

6 minutes ago, MrFisc said:

Unfortunately, I'm unable to see that page (not sure why).

https://invisioncommunity.com/files/file/8963-ne-oembedservices-management/

Not sure if 'Visitors' will be able to view that though.

6 minutes ago, MrFisc said:

To do this, would I need to make a Hook for `\IPS\Parsers\Text`

Yes - look at oembedservice() as mentioned.

6 minutes ago, MrFisc said:

Where do I place my "endpoint"?

On a web server.....again, look at oembedservice() for what it does. It provides a url endpoint if a link contains the domain listed...

image.thumb.png.5eb500744c0854260df62bbe64e1242f.png

That endpoint needs to generate response code which is then parsed by the editor to produce the embedded content.

Link to comment
Share on other sites

What is the 

static::EMBED_VIDEO

part referring to? It looks like it's a constant that tells the system that this content is to be embedded using a specific template for the type of content that it is. Understand, that there doesn't exist any true embed code for what I'm trying to embed. Instead I'm trying to generate a custom HTML template that can be "embedded" so to speak (really it would just be HTML that would replace the URL in the Source portion of the WYSIWYG editor). 

My original thought before all of this was to have JavaScript that would listen for URL pastes into the WYSIWYG editor, and replace them in the source portion with the desired template. But this doesn't seem like it's the official way to go about doing this.

 

9 minutes ago, Nathan Explosion said:

I'm referring to my corrected link.....

I was able to find the proper link 🙂 

Link to comment
Share on other sites

1 minute ago, MrFisc said:

AFAIK they don't currently offer an oEmbed service

OK.

Let's take Youtube as an example.....

This link https://www.youtube.com/watch?v=Z1BCujX3pw8 is sent to the youtube endpoint https://www.youtube.com/oembed with a query string: https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=Z1BCujX3pw8 (click that link to see what Youtube outputs)

That type of response is what you need to generate somehow....I'd suggest a PHP file on your own server which will take a URL query string, process it and return the JSON format that is needed to provide the 'html' information that IPS code will then process to return the embed HTML.

 

Link to comment
Share on other sites

23 minutes ago, Nathan Explosion said:

OK.

Let's take Youtube as an example.....

This link https://www.youtube.com/watch?v=Z1BCujX3pw8 is sent to the youtube endpoint https://www.youtube.com/oembed with a query string: https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=Z1BCujX3pw8 (click that link to see what Youtube outputs)

That type of response is what you need to generate somehow....I'd suggest a PHP file on your own server which will take a URL query string, process it and return the JSON format that is needed to provide the 'html' information that IPS code will then process to return the embed HTML.

 

It turns out that Medal does have an oEmbed API, I contacted a staff member there that I know and he supplied me with the information that I needed. So I believe I can get this working now. Thanks so much for the help!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...