iframe and URL
#1
Hello everyone

I would like to activate iframe via mycode. 
I have the following code: 

For iframe:
\[iframe\](.*?)\[/iframe\]

Replacement: 
<iframe src="$1" width="800px" height="500px"><a href="$1"></a></iframe>

The problem is, that the link inside the iframe code gets replaced by the url Mycode rule. 
I tried it to place it in first and last order, which both didnt work. 

Any ideas?

Thx for any help.
Reply
#2
You will have to restructure your code, but this will work:

Regex:

\[iframe=(.*?)\]

Replacement:

same, BUT

The anchor you have in your replacement will not be functional at all. The iFrame takes over the space.

So you would use [iframe={url here}]
[retired]
Reply
#3
Thank you for your answer.

I tried:
1. RegEx: \[iframe=(.*?)\] and replacment: \[iframe=(.*?)\]

and

2. RegEx: \[iframe=(.*?)\](.*?)\[iframe=(.*?)\] and Replacement: \[iframe=(.*?)\](.*?)\[iframe=(.*?)\]

Both didnt work. What am I doing wrong?
Reply
#4
I made two tests, using the same replacement:

Regex1 : \[iframe="(.*?)"\]
Regex2 : \[iframe\](.*?)\[/iframe\]

Replacement : <iframe src="$1" width="800px" height="500px"></iframe>
This is the only custom MyBB I have, but the two tests worked fine.

Have you other MyCode or any plugin modifying the posts ?
Tchat en français
Do not ask me help through PM or Discord

Reply
#5
(2019-07-02, 11:36 AM)theliadir Wrote: Thank you for your answer.

I tried:
1. RegEx: \[iframe=(.*?)\] and replacment: \[iframe=(.*?)\]

and

2. RegEx: \[iframe=(.*?)\](.*?)\[iframe=(.*?)\] and Replacement: \[iframe=(.*?)\](.*?)\[iframe=(.*?)\]

Both didnt work. What am I doing wrong?

No, you should use this replacement:

Replacement: <iframe src="$1" width="800px" height="500px"></iframe>

Sorry, I wasn't clear. The anchor (link) in the iframe won't do anything, so just remove it.

Then use the tag like this: [iframe={url}]
[retired]
Reply
#6
So I dissabled my editor and all my MyCodes for the moment. I installed CKEditor and SimpleCKEditor but both are dissabled. 

With the following MyCode:
RegEx: \[iframe\](.*?)\[/iframe\]
Replacement: <iframe src="$1" width="800px" height="500px"></iframe>

I get this in the source code: 

<iframe src="<a href=" https:="" www.youtube.com="" embed="" pkh8utuejgw"="" target="_blank" rel="noopener" class="mycode_url">https://www.youtube.com/embed/Pkh8UtuejGw</a>" width="800px" height="500px"></iframe>

if you check src="https..." gets replaced by src="<a href=" https..." which breaks the code. 
So the url inside the src tag gets also replaced by a a tag which makes no sense!

Any ideas?
Reply
#7
That's odd. I tested that code on my local fresh copy of MyBB 1.8.21 without issue.

I'll look again when I get home.

EDIT: I just realized that you aren't using my code:

Regex:

\[iframe=(.*?)\]

Replacement:

<iframe src="$1" width="800px" height="500px"></iframe>
[retired]
Reply
#8
So you paste the embed code from youtube in your post ?

You have to put in your post: [iframe]https://www.youtube.com/embed/Pkh8UtuejGw[/iframe]
Tchat en français
Do not ask me help through PM or Discord

Reply
#9
@Crazycat: Yes, that's what I've been doing. 

@Wildcard
Yes, sorry. It worked now with the Code you provided:

So the Solution here is: 

MyCode:
1. RegEx: \[iframe=(.*?)\]
2. Replacement: <iframe src="$1" width="800px" height="500px"></iframe>

and in the Post: 
[iframe=https://www.youtube.com/embed/Pkh8UtuejGw]

I really appreaciate your help and patience. 

Thank you. 
Reply
#10
No problem. Just glad you got it working Cool
[retired]
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)