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

MediaPlaceholder multiple and gallery properties #9139

Merged
merged 4 commits into from
Aug 24, 2018

Conversation

LuigiPulcini
Copy link
Contributor

The gallery property should be set to true only after checking that the selected type of media is not audio.

Description

The MediaPlaceholder component can be used to select multiple files also with audio files. In addition to being counterintuitive, forcing gallery to be true only based on the multiple property does not allow to work with audio files. In fact, when type is set to "audio" and multiple is true, the MediaUpload component only shows images

Additional Information

In addition to the proposed change, it could be possible to add another line as follows:

playlist={ multiple && type === "audio" }

This could be done when a playlist block is finally added to Gutenberg.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

The `gallery` property should be set to `true` only after checking that the selected `type` of media is not `audio`.
@LuigiPulcini LuigiPulcini changed the title MediaPlaceholder multiple property MediaPlaceholder multiple and gallery properties Aug 19, 2018
@@ -127,7 +127,7 @@ class MediaPlaceholder extends Component {
{ __( 'Upload' ) }
</FormFileUpload>
<MediaUpload
gallery={ multiple }
gallery={ multiple && type != "audio" }
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say, it's probably better if the check is multiple && type === 'image'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree.

And, actually, there should be two different lines, one for gallery and one for playlist, like this.

gallery={ multiple && type === 'image' }
playlist={ multiple && type === 'audio' }

gallery and playlist check for multiple and type, being gallery true when multiple is true and type is image, while playlist true when multiple is true and type is audio.
@@ -127,7 +127,8 @@ class MediaPlaceholder extends Component {
{ __( 'Upload' ) }
</FormFileUpload>
<MediaUpload
gallery={ multiple }
gallery={ multiple && type === "image" }
playlist={ multiple && type === "audio" }
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we support playlists yet in MediaUpload and even if we did, there are playlists of videos.

I think it's probably better to remove until #9169

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hear what you are saying regarding the video playlists and that could be easily changed to something accommodating for both audio and video types.

But I have to disagree regarding the possibility to wait until #9169: analyzing that code – particularly this part of the edit.js file – it is clear that it simply tried to circumvent the current MediaPlaceholder limitation, recreating the whole component inside the edit.js file, only because the current MediaPlaceholder implementation does not allow to manage media types other than images.

So, I believe it is important to fix the MediaPlaceholder before refactoring the playlist block, which will allow a more streamlined playlist component as well.

Copy link
Contributor

@youknowriad youknowriad Aug 24, 2018

Choose a reason for hiding this comment

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

The underlying MediaUpload component doesn't support the playlist yet. So why to pass a useless prop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right.
I edited the proposed change accordingly.

My point is the MediaPlaceholder should be fixed before refactoring the playlist because of the reasons I explained above.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree it would be great if the MediaUpload also supports playlists out of the box.

The `gallery` property is set to `true` when `multiple` is `true` and `type === "image"`
@@ -127,7 +127,7 @@ class MediaPlaceholder extends Component {
{ __( 'Upload' ) }
</FormFileUpload>
<MediaUpload
gallery={ multiple }
gallery={ multiple && type === "image" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there's an eslint issue here. We should use single quotes. You can test locally using npm run lint or install an eslint plugin for your IDE.

changed type check using single quotes instead of double quotes
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@youknowriad youknowriad merged commit d7eb4f6 into WordPress:master Aug 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants