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

Always prefer "large" image size #11682

Merged
merged 6 commits into from
Nov 15, 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/cover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export const settings = {
}
mediaType = media.type;
}

setAttributes( {
url: media.url,
id: media.id,
Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/gallery/edit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External Dependencies
*/
import { filter, pick } from 'lodash';
import { filter, pick, get } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -45,7 +45,9 @@ export function defaultColumnsNumber( attributes ) {
}

export const pickRelevantMediaFiles = ( image ) => {
return pick( image, [ 'alt', 'id', 'link', 'url', 'caption' ] );
const imageProps = pick( image, [ 'alt', 'id', 'link', 'caption' ] );
imageProps.url = get( image, [ 'sizes', 'large', 'url' ] ) || get( image, [ 'media_details', 'sizes', 'large', 'source_url' ] ) || image.url;
return imageProps;
};

class GalleryEdit extends Component {
Expand Down
4 changes: 3 additions & 1 deletion packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ const LINK_DESTINATION_CUSTOM = 'custom';
const ALLOWED_MEDIA_TYPES = [ 'image' ];

export const pickRelevantMediaFiles = ( image ) => {
return pick( image, [ 'alt', 'id', 'link', 'url', 'caption' ] );
const imageProps = pick( image, [ 'alt', 'id', 'link', 'caption' ] );
imageProps.url = get( image, [ 'sizes', 'large', 'url' ] ) || get( image, [ 'media_details', 'sizes', 'large', 'source_url' ] ) || image.url;
return imageProps;
};

/**
Expand Down
9 changes: 8 additions & 1 deletion packages/block-library/src/media-text/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import classnames from 'classnames';
import { get } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -50,6 +51,7 @@ class MediaTextEdit extends Component {
const { setAttributes } = this.props;

let mediaType;
let src;
// for media selections originated from a file upload.
if ( media.media_type ) {
if ( media.media_type === 'image' ) {
Expand All @@ -63,11 +65,16 @@ class MediaTextEdit extends Component {
mediaType = media.type;
}

if ( mediaType === 'image' ) {
// Try the "large" size URL, falling back to the "full" size URL below.
src = get( media, [ 'sizes', 'large', 'url' ] ) || get( media, [ 'media_details', 'sizes', 'large', 'source_url' ] );
}

setAttributes( {
mediaAlt: media.alt,
mediaId: media.id,
mediaType,
mediaUrl: media.url,
mediaUrl: src || media.url,
} );
}

Expand Down