Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaEmbed: disable URL autoparsing #91

Closed
nerestaren opened this issue Feb 28, 2018 · 3 comments
Closed

MediaEmbed: disable URL autoparsing #91

nerestaren opened this issue Feb 28, 2018 · 3 comments
Labels

Comments

@nerestaren
Copy link

nerestaren commented Feb 28, 2018

Hi,

is there any way to disable URL conversion to media embeds while keeping the [media] bbcode?

Thank you.

Edit: I meant the [media] bbcode. You still understood me.

@JoshyPHP
Copy link
Member

Yes, you can remove the plugin after configuration or disable it at runtime.

// After configuration
unset($configurator->MediaEmbed);

// At runtime
$parser->disablePlugin('MediaEmbed');

@MrStonedOne
Copy link

MrStonedOne commented Jan 10, 2022

@JoshyPHP this should be re-opened as it did not answer the question.

mediaembed works for both urls and things inside the media bbcode tag, they (and myself since i got here from google) only want to disable url auto-parsing while keeping the [media] parsing. you gave instructions that seems to me would disable both.

@JoshyPHP
Copy link
Member

As far as I can tell, it works as described.

$configurator = new s9e\TextFormatter\Configurator;
$configurator->MediaEmbed->add('youtube');
unset($configurator->MediaEmbed);

extract($configurator->finalize());

$text = "[media]https://www.youtube.com/watch?v=jNQXAC9IVRw[/media]\n"
      . 'https://www.youtube.com/watch?v=jNQXAC9IVRw';
$xml  = $parser->parse($text);

die("$xml\n");
$configurator = new s9e\TextFormatter\Configurator;
$configurator->MediaEmbed->add('youtube');

extract($configurator->finalize());

$parser->disablePlugin('MediaEmbed');

$text = "[media]https://www.youtube.com/watch?v=jNQXAC9IVRw[/media]\n"
      . 'https://www.youtube.com/watch?v=jNQXAC9IVRw';
$xml  = $parser->parse($text);

die("$xml\n");
<r><YOUTUBE id="jNQXAC9IVRw"><s>[media]</s>https://www.youtube.com/watch?v=jNQXAC9IVRw<e>[/media]</e></YOUTUBE>
https://www.youtube.com/watch?v=jNQXAC9IVRw</r>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants