Skip to content

Commit

Permalink
use smaller images for previews
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Dec 23, 2022
1 parent d90e553 commit 7971513
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
13 changes: 7 additions & 6 deletions packages/block-editor/src/components/inserter/media-tab/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import { store as blockEditorStore } from '../../../store';
* WordPress media blocks(image, video, audio).
*
* @typedef {Object} InserterMediaItem
* @property {string} title The title of the media item.
* @property {string} src The source url of the media item.
* @property {number} [id] The WordPress id of the media item.
* @property {number|string} [sourceId] The id of the media item from external source.
* @property {string} [alt] The alt text of the media item.
* @property {string} [caption] The caption of the media item.
* @property {string} title The title of the media item.
* @property {string} url The source url of the media item.
* @property {string} [previewUrl] The preview source url of the media item to display in the media list.
* @property {number} [id] The WordPress id of the media item.
* @property {number|string} [sourceId] The id of the media item from external source.
* @property {string} [alt] The alt text of the media item.
* @property {string} [caption] The caption of the media item.
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function getBlockAndPreviewFromMedia( media, mediaType ) {
const PreviewTag = mediaTypeTag[ mediaType ];
const preview = (
<PreviewTag
src={ mediaSrc }
src={ media.previewUrl || mediaSrc }
alt={ alt }
controls={ mediaType === 'audio' ? true : undefined }
inert="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const coreMediaFetch = async ( query = {} ) => {
...mediaItem,
alt: mediaItem.alt_text,
url: mediaItem.source_url,
previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
caption: mediaItem.caption?.raw,
} ) );
};
Expand Down Expand Up @@ -140,6 +141,7 @@ const inserterMediaCategories = [
sourceId: result.id,
id: undefined,
caption: getOpenverseCaption( result ),
previewUrl: result.thumbnail,
} ) );
},
hasAvailableMedia: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/components/media-categories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const coreMediaFetch = async ( query = {} ) => {
...mediaItem,
alt: mediaItem.alt_text,
url: mediaItem.source_url,
previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
caption: mediaItem.caption?.raw,
} ) );
};
Expand Down Expand Up @@ -140,6 +141,7 @@ const inserterMediaCategories = [
sourceId: result.id,
id: undefined,
caption: getOpenverseCaption( result ),
previewUrl: result.thumbnail,
} ) );
},
hasAvailableMedia: true,
Expand Down

1 comment on commit 7971513

@github-actions
Copy link

@github-actions github-actions bot commented on 7971513 Dec 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3764779779
📝 Reported issues:

Please sign in to comment.