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

Lock post saving when media is being uploaded #16030

Closed
sndrgb opened this issue Jun 7, 2019 · 6 comments
Closed

Lock post saving when media is being uploaded #16030

sndrgb opened this issue Jun 7, 2019 · 6 comments
Labels
[Block] Audio Affects the Audio Block [Block] Image Affects the Image Block [Block] Video Affects the Video Block [Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended

Comments

@sndrgb
Copy link

sndrgb commented Jun 7, 2019

Hi everybody, I need an help building a gutenberg block. I'm using MediaPlaceholder component as starting for add images (it's a carousel), but I have a lot of problems when I use the "load" button instead of "view library":

<MediaPlaceholder
                        icon="format-gallery"
                        className={ props.className }
                        labels={ {
                            title: __('Carousel'),
                            name: __('images'),
                        } }
                        onSelect={ onSelectImages }
                        accept="image/*"
                        type="image"
                        multiple
                    />
const onSelectImages = function(selectedImages) {
            const array = [ ...images, ...selectedImages ]
            const updatedImages = array.map((img, index) => {
                if (img.media_details) {
                    Object.assign(img, {
                        width: img.width,
                        height: img.height,
                        id: index,
                        imgid: img.id,
                    })
                }

                return Object.assign(img, { id: index })
            });

            setAttributes({ images: updatedImages });
        }

the big problem is that I cannot render on the save function images, because I need size of it and If the editor clicks "update article" before images loads async I cannot get img.media_details.sizes because it returns only an url with a blob like: {url: "blob:" }. what can I do?

@J0ker98
Copy link

J0ker98 commented Jun 7, 2019

I'm having the same problem

@swissspidy swissspidy added [Type] Help Request Help with setup, implementation, or "How do I?" questions. [Feature] Media Anything that impacts the experience of managing media labels Jun 7, 2019
@youknowriad youknowriad changed the title Wait image sizes before save function Lock post saving when media is being uploaded Jan 15, 2020
@youknowriad youknowriad added [Block] Image Affects the Image Block [Type] Bug An existing feature does not function as intended and removed [Type] Help Request Help with setup, implementation, or "How do I?" questions. labels Jan 15, 2020
@youknowriad youknowriad added [Block] Audio Affects the Audio Block [Block] Video Affects the Video Block labels Feb 12, 2020
@paaljoachim
Copy link
Contributor

Hi @sndrgb

Please recheck the issue.
Thanks!

@sndrgb
Copy link
Author

sndrgb commented Mar 9, 2021

I'll check it out soon, thanks a lot!

@adamsilverstein
Copy link
Member

This should be fixed by #41120

@paaljoachim
Copy link
Contributor

Thanks for letting us know in this thread Adam @adamsilverstein
I will go ahead and close this issue. It can always be reopened if that is needed.

@adamsilverstein
Copy link
Member

Note: this is replaced by #39223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Audio Affects the Audio Block [Block] Image Affects the Image Block [Block] Video Affects the Video Block [Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

6 participants