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

Gallery block: fix bug with stalled upload when image size too large #34371

Merged
merged 5 commits into from
Sep 2, 2021
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
17 changes: 16 additions & 1 deletion packages/block-library/src/gallery/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@ figure.wp-block-gallery {
flex: 0 0 100%;
}

.components-form-file-upload {
> .components-form-file-upload {
flex-basis: 100%;
}

.wp-block-image {
.components-notice.is-error {
display: block;
}
.components-notice__content {
margin: 4px 0;
}
.components-notice__dismiss {
position: absolute;
top: 0;
right: 5px;
}
}

// @todo: this deserves a refactor, by being moved to the toolbar.
.block-editor-media-placeholder.is-appender {
.components-placeholder__label {
Expand Down
13 changes: 4 additions & 9 deletions packages/block-library/src/gallery/use-get-media.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ export default function useGetMedia( innerBlockImages ) {

const imageMedia = useSelect(
( select ) => {
if (
! innerBlockImages?.length ||
innerBlockImages.some(
( imageBlock ) => ! imageBlock.attributes.id
)
) {
if ( ! innerBlockImages?.length ) {
return currentImageMedia;
}

const imageIds = innerBlockImages.map(
( imageBlock ) => imageBlock.attributes.id
);
const imageIds = innerBlockImages
.map( ( imageBlock ) => imageBlock.attributes.id )
.filter( ( id ) => id !== undefined );

if ( imageIds.length === 0 ) {
return currentImageMedia;
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export function ImageEdit( {
} );
}

const isTemp = isTemporaryImage( id, url );
let isTemp = isTemporaryImage( id, url );

// Upload a temporary image on mount.
useEffect( () => {
Expand All @@ -264,6 +264,7 @@ export function ImageEdit( {
},
allowedTypes: ALLOWED_MEDIA_TYPES,
onError: ( message ) => {
isTemp = false;
noticeOperations.createErrorNotice( message );
setAttributes( {
src: undefined,
Expand Down