-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Video Editor: Add VideoPress poster picker #11653
Conversation
let editText = translate( 'Edit Image' ); | ||
|
||
if ( 'video' === mimePrefix ) { | ||
editText = translate( 'Edit Thumbnail' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 79 times:
translate( 'Thumbnail' )
ES Score: 7
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
b41e9d7
to
10a02e5
Compare
f2caf7e
to
9b494b4
Compare
596251e
to
275a137
Compare
275a137
to
5ccf071
Compare
7f53819
to
57d607f
Compare
a273540
to
f14a88f
Compare
a33e749
to
599bd53
Compare
c802025
to
72f6b28
Compare
a2bd5c6
to
e32ab0e
Compare
@@ -36,6 +37,7 @@ class EditorMediaModalDetailPreviewVideoPress extends Component { | |||
|
|||
componentDidMount() { | |||
this.loadInitializeScript(); | |||
window.addEventListener( 'message', this.receiveMessage, false ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason this isn't unloaded in componentWillUnmount
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's being removed in the destroy
function, which is called by componentWillUnmount
. destroy
is also called in componentDidUpdate
, since if the VideoPress ID changes, the player needs to be re-initialized.
receiveMessage = ( event ) => { | ||
if ( event.origin && event.origin !== location.origin ) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very good!
|
||
const data = 'string' === typeof event.data | ||
? JSON.parse( event.data ) | ||
: event.data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was it with @gwwar that I recently held a discussion on this? there's something about this construction I don't like (also it's unsafe because JSON.parse()
throws on invalid syntax) because it assumes that string data is JSON data
I would be far more in favor of something else like this…
const parseEventData = data => {
try {
return JSON.parse( data );
} catch (e) {
return data;
}
}
…
const data = parseEventData( event.data );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the response is already JSON. I have no idea why I was trying to parse it. 🤦♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we want to use JSON data we will need to parse it, otherwise it's just a string…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? Not sure I follow, since event.data
is already an object. I discovered parsing wasn't necessary by actually trying to parse it and then realizing the catch
handler fired every time.
I was like, 'Calypso, JSON.parse( event.data )
!', and Calypso was all like Unexpected token o in JSON at position 1
! So buh bye JSON.parse
!
06ad32d
to
b17aae4
Compare
c5d2b14
to
0924df1
Compare
@ockham Awesome! Tested everything again and it's all still working so I'm going to go ahead and deploy. Thx! 😃 |
We noticed that this is live for staging, but still disabled in production ( https://github.com/Automattic/wp-calypso/blob/master/config/stage.json#L82 vs https://github.com/Automattic/wp-calypso/blob/master/config/production.json#L77 ). Is there a timeline for rolling it out to prod? 634025-zen |
Also requested in production here: 624739-zen |
@kraftbj @chaselivingston I'll get a PR together to deploy to production. Cheers. |
PR is here and is awaiting review. |
This PR enables choosing a custom VideoPress poster by either selecting a particular frame of the video or by uploading a custom image.
Testing
Test using a site that has VideoPress enabled (e.g. a WP.com site that has a Premium plan or a Jetpack site that has a Jetpack Premium plan and VideoPress enabled in Jetpack settings).
The Video Editor can be accessed in the post editor by selecting "Add Media" from the toolbar dropdown, selecting a video, clicking the "Edit" button, and then clicking the "Edit Thumbnail" button.
It can also be accessed by clicking "Media" in the sidebar, selecting a video, clicking the "Edit" button, and then clicking the "Edit Thumbnail" button:
If the video cannot be loaded or an error occurs when updating the poster, the following message is shown: