Skip to content

Commit

Permalink
Embed: adjust width of iframe and inline toolbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 11, 2017
1 parent dddce24 commit 182fd3a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 3 additions & 1 deletion blocks/library/embed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Placeholder from 'components/placeholder';
/**
* Internal dependencies
*/
import './style.scss';
import { registerBlock, query } from '../../api';
import Editable from '../../editable';

Expand Down Expand Up @@ -40,7 +41,7 @@ registerBlock( 'core/embed', {
}

return (
<figure>
<figure className="blocks-embed">
<div className="iframe-overlay">
<iframe src={ url } title={ title } />
</div>
Expand All @@ -53,6 +54,7 @@ registerBlock( 'core/embed', {
onFocus={ setFocus }
onChange={ ( value ) => setAttributes( { caption: value } ) }
inline
inlineToolbar
/>
) : null }
</figure>
Expand Down
18 changes: 18 additions & 0 deletions blocks/library/embed/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.blocks-embed {
margin: 0;
}

.blocks-embed .iframe-overlay {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%; /* 16:9 */
}

.blocks-embed iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
2 changes: 1 addition & 1 deletion post-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ window._wpGutenbergPost = {
'<!-- /wp:core/text -->',

'<!-- wp:core/embed url="https://www.youtube.com/watch?v=Nl6U7UotA-M" -->',
'<figure><iframe width="560" height="315" src="//www.youtube.com/embed/Nl6U7UotA-M" frameborder="0" allowfullscreen></iframe><figcaption>State of the Word 2016</figcaption></figure>',
'<figure><iframe src="//www.youtube.com/embed/Nl6U7UotA-M" frameborder="0" allowfullscreen></iframe><figcaption>State of the Word 2016</figcaption></figure>',
'<!-- /wp:core/embed -->',

'<!-- wp:core/heading -->',
Expand Down

0 comments on commit 182fd3a

Please sign in to comment.