Skip to content

Commit b32b8b9

Browse files
committed
Data sources incorrectly rendered.
1 parent 8233f24 commit b32b8b9

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/ableplayer.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ function ableplayer_shortcode( $atts, $content = null ) {
426426
'ableplayer'
427427
);
428428

429-
$source = '';
429+
$source = '';
430+
$datasource = '';
430431
if ( ! ( $all_atts['youtube-id'] || $all_atts['vimeo-id'] || $all_atts['media-id'] ) ) {
431432
// Shortcode must have one of YouTube, Vimeo, or local video source.
432433
return false;
@@ -437,26 +438,27 @@ function ableplayer_shortcode( $atts, $content = null ) {
437438
if ( ! $media_id ) {
438439
return false;
439440
} else {
440-
$type = get_post_mime_type( $media_id );
441-
$source = '<source type="' . esc_attr( $type ) . '" src="' . esc_url( $media_id ) . '">';
441+
$type = get_post_mime_type( $all_atts['media-id'] );
442+
$source = '<source type="' . esc_attr( $type ) . '" src="' . esc_url( $media_id ) . '"%datasrc%>' . PHP_EOL;
442443
}
443444
}
444445
if ( $all_atts['media-desc-id'] ) {
445446
// If Video ID is set but is not a valid URL, return.
446447
$media_desc_id = ( is_numeric( $all_atts['media-desc-id'] ) ) ? wp_get_attachment_url( $all_atts['media-desc-id'] ) : $all_atts['media-desc-id'];
447448
if ( $media_desc_id ) {
448-
$type = get_post_mime_type( $media_desc_id );
449-
$source = '<source data-desc-src type="' . esc_attr( $type ) . '" src="' . esc_url( $media_desc_id ) . '">';
449+
$datatype = get_post_mime_type( $all_atts['media-desc-id'] );
450+
$datasource .= ( $type === $datatype ) ? ' data-desc-src="' . esc_url( $media_desc_id ) . '"' : '';
450451
}
451452
}
452453
if ( $all_atts['media-asl-id'] ) {
453454
// If Video ID is set but is not a valid URL, return.
454-
$media_desc_id = ( is_numeric( $all_atts['media-asl-id'] ) ) ? wp_get_attachment_url( $all_atts['media-asl-id'] ) : $all_atts['media-desc-id'];
455-
if ( $media_desc_id ) {
456-
$type = get_post_mime_type( $media_desc_id );
457-
$source = '<source data-sign-src type="' . esc_attr( $type ) . '" src="' . esc_url( $media_desc_id ) . '">';
455+
$media_asl_id = ( is_numeric( $all_atts['media-asl-id'] ) ) ? wp_get_attachment_url( $all_atts['media-asl-id'] ) : $all_atts['media-desc-id'];
456+
if ( $media_asl_id ) {
457+
$datatype = get_post_mime_type( $all_atts['media-asl-id'] );
458+
$datasource .= ( $type === $datatype ) ? ' data-sign-src="' . esc_url( $media_asl_id ) . '"' : '';
458459
}
459460
}
461+
$source = str_replace( '%datasrc%', $datasource, $source );
460462

461463
$tracks = array();
462464
$kinds = array(
@@ -555,7 +557,7 @@ function ableplayer_shortcode( $atts, $content = null ) {
555557
if ( ! empty( $all_atts['vimeo-desc-id'] ) ) {
556558
$o .= ' data-vimeo-desc-id="' . esc_attr( $all_atts['vimeo-desc-id'] ) . '"';
557559
}
558-
$o .= '>';
560+
$o .= '>' . PHP_EOL;
559561

560562
$o .= $source;
561563

@@ -569,7 +571,7 @@ function ableplayer_shortcode( $atts, $content = null ) {
569571
}
570572

571573
// end media tag.
572-
$o .= '</video>';
574+
$o .= PHP_EOL . '</video>';
573575

574576
return $o;
575577
}

0 commit comments

Comments
 (0)