It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

User Macros - iFrame

I would like to change a custom macros for embedding iFrames to allow users to embed more than one iFrame per page. Currently users would like to embed videos via iFrame, but the iFrame only allows one embed per page or rather cuts off the second iFrame embed. 

 

Basic code for the user macros is as follows and we are using Confluence 5.6.6:

## Requests a url from the user to place into an <iframe>. Also asks for height and width of the frame

## @param url:title=iframe address|type=string|required=true|desc=URL of the content to be placed in the iframe
## @param height:title=Height|type=string|required=false|desc=Specify px or % (example: 200px)|default=250px
## @param width:title=Width|type=string|required=false|desc=Specify px or % (example: 400px)|default=400px

<iframe src="$paramurl" height="$paramheight" width="$paramwidth"></iframe>

3 answers

No need for CDATA. You need to have a line break before the closing </iframe> tag. Something like:

&lt;iframe src="$paramurl" height="$paramheight" width="$paramwidth"&gt;
&lt;/iframe&gt;

You ROCK!!  

FYI, if anyone here uses Microsoft Stream to store videos, and then if you use the Share | Embed feature to get a string of HTML code to put in an HTML macro in a Confluence page, you'll see extraneous HTML code after your video unless you do as Alex says, "You need to have a line break before the closing </iframe> tag."  The Microsoft Stream string puts the </iframe> tag on the same line as the <iframe> tag.

Hi,

It seems like it is related to incorrect rendering of the user macro. 

As when I tried your user macro it does create only one iframe and it skips the footer part...

Something related: https://jira.atlassian.com/browse/CONF-25507 and https://answers.atlassian.com/questions/11969031

The above mentioned use-cases are more complex, but the point here is that user macro renderer fails on certain scenarios. I have made a comment on the issue in Confluence JIRA to use the custom renderer, but I have not tried it myself.

Anyway, if you get into trouble  you can give a try to our plugin, https://marketplace.atlassian.com/plugins/com.vertuna.confluence.plugins.confirest. You can basically include any parts of the page you want or any other content (structured such as RSS, XML, JSON or unstructured, such as HTML), inside your Confluence page

Thanks Sash, Can you clarify a bit by what you mean by incorrect rendering? The code itself is written incorrectly or just not written in a way that allows for multiple iframes, ie skipping to the footer?

See the related bug CONF-25507, and also when you have your user macro rendered it brakes the footer, very similar to the usecases mentioned in the bug.

As including 2 and more iframes using an HTML macro works fine... so it is something with User macro renderer

Adding a CData tag fixes the embed two iframes problem, but now it displays a "]]>" before each iframe? I don't seem to have any missing tags. Is this a nesting problem. Copied below is the code:

 

<![CDATA[<iframe></iframe>]]>
<iframe src="$paramurl" height="$paramheight" width="$paramwidth"></iframe>

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Off-topic

Friday Fun: Virtual dance party!

Do dance parties help you relieve stress? How about *virtual dance parties*? My team holds virtual dance parties to brighten the mood of a tough day or celebrate an upcoming weekend.  Want t...

151 views 21 8
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you