Add video block size validation in the Media Library#2755
Add video block size validation in the Media Library#2755swissspidy merged 37 commits intodevelopfrom
Conversation
This doesn't disable the 'Select' button now, though it shows a notice both in the AMP Story editor and the normal post or page block editor.
Before, this simply displayed a notice. Now, it actually disables the button.
…tion I didn't write this originally, but I used this same logic for the file type notice. So instead of simply copy and pasting it, this extracts it into a separate function.
Refactor much of the existing logic, which was for featured images. Rename a file and many functions.
There was duplicated logic, so use that function in place of the copy-pasted code.
It looks like that wasn't preventing .mov files from appearing. Also, the new logic uses ALLOWED_MEDIA_TYPES as passed in allowedTypes. It checks that the attachment.get( 'type' ) matches that, and the attachment.get( 'type' ) is never 'video/mp4'. That is only the attachment.get( 'mime' ).
There was a file that should have been moved, but I forgot to delete it.
There an error: fatal: Path 'amp.php' exists on disk, but not in 'eb9bb06b77d811ba80ca70ec60fbe551aea4ca73'. Pascal had suggested an empty commit for this.
It looks like this needed a 'select' handler. So add one here.
Add a mockClasses.js file to store some mocks. And use this for the tests in isFileTypeAllowed.js.
That seems to have caused .mov files to appear in the Background Media. So revert the change to that, and instead change isFileTypeAllowed() to return true whene a mime type matches a value in the allowedTypes array.
This PR already blocked selecting uploading them. But if they were uploaded before, they would still display in the 'Media Library' tab of the Media Library. So this blocks displaying them in that tab if they were uploaded before.
This caused a failed Travis build, as it was imported but not used.
Before, some of these were joined using a comma. Instead, keep to the convention in the rest of this PR.
There shouldn't have been a period in the middle of the sentence.
These functions will be useful in displaying the notice for video size, and that logic is in commmon/. So move all of this to common/.
This applies to the Core Video block and the AMP Stories 'Background Media' component. Also, add unit tests for the helper methods.
The heading mentioned the file size, where it should have been type.
When there were 2 notices, like for the wrong video type and file size, the notices overlapped some of the media. So add a class to the media library if there are 2 notices. And add a style rule for that class.
|
Steps To Test
|
|
This isn't quite ready for review, as it's still branched off the |
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the ℹ️ Googlers: Go here for more info. |
cf596ab to
e2e81c0
Compare
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
Likely not the most common use case but looks like displaying the warning based on URL stops showing when I do the following:
|
Actually, there is no need to change a previous video, just using "Upload" directly and choosing a video exceeding the limits won't show the warning since the Media Library doesn't open then. |
Cannot reproduce this.
Cannot reproduce either. Edit: now I can see it 🤷♂
Made the tests much more readable now in 3ce5e76. |
I guess we can then just show the warning in the sidebar. |
|
@miina Mind checking again? |
assets/src/stories-editor/components/with-enforced-video-upload-type.js
Outdated
Show resolved
Hide resolved
Interesting. Will try to reproduce. |
Note that I was using this video. |
|
Looks like it was a rounding issue. |







developand target this PR todevelopCloses #2560