Skip to content

Commit 1489019

Browse files
authored
fix (video popup): upload date error on newly uploaded videos (#3641)
* fix video upload date error * fix implementation
1 parent 9338467 commit 1489019

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/block/video-popup/edit.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,24 @@ const InspectorControls = memo( props => {
183183
videoUploadDate: '',
184184
} ) }
185185
onChange={ media => {
186+
let videoUploadDate = null
187+
188+
if ( media.date ) {
189+
try {
190+
videoUploadDate = media.date instanceof Date
191+
? media.date.toISOString()
192+
: new Date( media.date ).toISOString()
193+
} catch ( error ) {
194+
videoUploadDate = null
195+
}
196+
}
197+
186198
props.setAttributes( {
187199
videoLink: media.url,
188200
videoId: media.url,
189201
videoName: media.title, // Use title, description and date from media library for video schema
190-
videoDescription: media.description,
191-
videoUploadDate: media.date.toISOString(),
202+
videoDescription: media.description || '',
203+
videoUploadDate: videoUploadDate ?? undefined,
192204
} )
193205
} }
194206
imageId={ urlIsVideo( props.videoLink ) ? props.videoId : '' }

0 commit comments

Comments
 (0)