MicroTiny: better support for YouTube videos

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
creopard
Forum Members
Forum Members
Posts: 47
Joined: Fri Nov 10, 2017 10:25 am
Location: .de
Contact:

MicroTiny: better support for YouTube videos

Post by creopard »

Unfortunately the MicroTiny editor strips the bold entry of an iframe like this completely (by default):
<__iframe style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" src="https://www.youtube-nocookie.com/embed/LONGURL" width="560" height="315" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></__iframe>
(However, the "allow" entry is useful on mobile devices to rotate the video automatically).

Please add the "allow" keyword in the tinymce.min.js like this:

Code: Select all

,d("iframe","sandbox seamless allowfullscreen")
becomes

Code: Select all

,d("iframe","sandbox seamless allowfullscreen allow")
and

Code: Select all

allowfullscreen:b.attr("allowfullscreen"),
becomes

Code: Select all

allowfullscreen:b.attr("allowfullscreen"),allow:b.attr("allow"),
Thank you!
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: MicroTiny: better support for YouTube videos

Post by Rolf »

This is where the power of UDT is very useful!!! Just a small example, UDT and tag in your editor:

Code: Select all

$id = isset($params['id']) ? $params['id'] : '';
$autoplay = isset($params['autoplay']) ? $params['autoplay'] : '0';

if ( !empty($id) )
{
  echo '<div class="video">';
  echo '<__iframe width="560" height="315" src="//www.youtube-nocookie.com/embed/' . $id . '?rel=0&amp;showinfo=0&autoplay=' . $autoplay . '" frameborder="0" allowfullscreen></__iframe>';
  echo '</div>';
}

Code: Select all

{youtube id='' autoplay='1'}

PS. In the code the word iframe has twice added "__" you dont need that of course ;)
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
creopard
Forum Members
Forum Members
Posts: 47
Joined: Fri Nov 10, 2017 10:25 am
Location: .de
Contact:

Re: MicroTiny: better support for YouTube videos

Post by creopard »

What a great idea, using a UDT for that.

There's only one downside:
I just noticed that UDTs do work in templates and normal content pages, but somehow they don't work in cgblog blog posts?!
In cgblog posts, when entering any UDT, e.g. {youtube} in MicroTiny, I just see the literal "{youtube}" and not the actual content from the UDT.

Any idea on this behaviour?
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: MicroTiny: better support for YouTube videos

Post by velden »

In your blog template use the {eval} tag for content you want to be parsed by the Smarty engine.

https://www.smarty.net/docsv2/en/langua ... n.eval.tpl

E.g. (not sure it's a valid example for CGBlog but you get the idea):

Code: Select all

{eval var=$entry->content}
User avatar
creopard
Forum Members
Forum Members
Posts: 47
Joined: Fri Nov 10, 2017 10:25 am
Location: .de
Contact:

Re: MicroTiny: better support for YouTube videos

Post by creopard »

Thanks for the hint - in the meantime I found the issue:

UDTs are not processed in cgblog when present in $entry->summary.
They will only work when present in $entry->content.
Last edited by creopard on Tue Jan 18, 2022 12:28 pm, edited 2 times in total.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: MicroTiny: better support for YouTube videos

Post by velden »

Nonsense in my opinion.
Try my solution but then use the summary 'variable'.
User avatar
creopard
Forum Members
Forum Members
Posts: 47
Joined: Fri Nov 10, 2017 10:25 am
Location: .de
Contact:

Re: MicroTiny: better support for YouTube videos

Post by creopard »

changing

Code: Select all

{$entry->summary|strip}
to

Code: Select all

{eval var=$entry->summary|strip}
did the trick, now UDTs are also processed in cgblog summaries.

Thanks for your help!
Post Reply

Return to “Modules/Add-Ons”