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

Do not make WordPress embeds responsive #10985

Merged
merged 2 commits into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/block-library/src/embed/core-embeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const common = [
title: 'WordPress',
icon: embedWordPressIcon,
keywords: [ __( 'post' ), __( 'blog' ) ],
responsive: false,
},
},
{
Expand Down
5 changes: 3 additions & 2 deletions packages/block-library/src/embed/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
import { createBlock } from '@wordpress/blocks';
import { RichText, BlockControls, BlockIcon, InspectorControls } from '@wordpress/editor';

export function getEmbedEditComponent( title, icon ) {
export function getEmbedEditComponent( title, icon, responsive = true ) {
return class extends Component {
constructor() {
super( ...arguments );
Expand Down Expand Up @@ -168,7 +168,8 @@ export function getEmbedEditComponent( title, icon ) {
previewDocument.body.innerHTML = html;
const iframe = previewDocument.body.querySelector( 'iframe' );

if ( iframe && iframe.height && iframe.width ) {
// If we have a fixed aspect iframe, and it's a responsive embed block.
if ( responsive && iframe && iframe.height && iframe.width ) {
const aspectRatio = ( iframe.width / iframe.height ).toFixed( 2 );
// Given the actual aspect ratio, find the widest ratio to support it.
for ( let ratioIndex = 0; ratioIndex < ASPECT_RATIOS.length; ratioIndex++ ) {
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/embed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export const settings = getEmbedBlockSettings( {
title: __( 'Embed' ),
description: __( 'The Embed block allows you to easily add videos, images, tweets, audio, and other content to your post or page.' ),
icon: embedContentIcon,
// Unknown embeds should not be responsive by default.
tofumatt marked this conversation as resolved.
Show resolved Hide resolved
responsive: false,
transforms: {
from: [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/embed/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ const embedAttributes = {
},
};

export function getEmbedBlockSettings( { title, description, icon, category = 'embed', transforms, keywords = [], supports = {} } ) {
export function getEmbedBlockSettings( { title, description, icon, category = 'embed', transforms, keywords = [], supports = {}, responsive = true } ) {
// translators: %s: Name of service (e.g. VideoPress, YouTube)
const blockDescription = description || sprintf( __( 'Add a block that displays content pulled from other sites, like Twitter, Instagram or YouTube.' ), title );
const edit = getEmbedEditComponent( title, icon );
const edit = getEmbedEditComponent( title, icon, responsive );
return {
title,
description: blockDescription,
Expand Down