Skip to content

Commit 42da01f

Browse files
Merge pull request #1080 from cloudinary/fix-audio-webm-files
Fix webm audio files
2 parents 9505364 + 43c7620 commit 42da01f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

php/class-delivery.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ public function is_deliverable( $attachment_id ) {
387387
if ( $is ) {
388388
$meta = wp_get_attachment_metadata( $attachment_id, true );
389389
$is = ! empty( $meta['width'] ) && ! empty( $meta['height'] );
390+
391+
// Webm audio files don't have width and height.
392+
if ( ! $is && ! empty( $meta['mime_type'] ) && 'audio/webm' === $meta['mime_type'] ) {
393+
$is = true;
394+
}
390395
}
391396

392397
if ( ! $is ) {

php/media/class-video.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ protected function build_video_embed( $source, $attributes = array(), $overwrite
392392

393393
// If it is an attachment, get the video metadata.
394394
if ( $attachment_id ) {
395+
395396
// Check for transformations.
396397
$transformations = $this->media->get_transformations( $attachment_id, array(), $overwrite_transformations );
397398
if ( ! empty( $transformations ) ) {
@@ -413,6 +414,12 @@ protected function build_video_embed( $source, $attributes = array(), $overwrite
413414
);
414415
$params['source']['transformation'] = array_merge( $streaming_transform, $transformations );
415416
}
417+
418+
$meta = wp_get_attachment_metadata( $attachment_id, true );
419+
420+
if ( ! empty( $meta['mime_type'] ) && 'audio/webm' === $meta['mime_type'] ) {
421+
$params['source']['source_types'] = array( 'audio' );
422+
}
416423
}
417424

418425
$video_defaults = array(

0 commit comments

Comments
 (0)