Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/js/media/views/attachment/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp

wp.media.mixin.removeAllPlayers();
this.$( 'audio, video' ).each( function (i, elem) {
var el = wp.media.view.MediaDetails.prepareSrc( elem );
new window.MediaElementPlayer( el, wp.media.mixin.mejsSettings );
new window.MediaElementPlayer( elem, wp.media.mixin.mejsSettings );
} );
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/js/media/views/audio-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ AudioDetails = MediaDetails.extend(/** @lends wp.media.view.AudioDetails.prototy
if ( audio.is(':hidden') ) {
audio.show();
}
this.media = MediaDetails.prepareSrc( audio.get(0) );
this.media = audio.get(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess audio files were also affected!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes — same story on the audio side. prepareSrc() was also mutating the audio sources in the media modal (this file was one of its three callers), and wp_audio_shortcode() appended the _= argument too. The removal covers both, so signed audio URLs stay intact as well. The latest commit (53a6770) is the full removal you asked for — no query parameter additions left anywhere.

} else {
audio.hide();
this.media = false;
Expand Down
19 changes: 5 additions & 14 deletions src/js/media/views/media-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,15 @@ MediaDetails = AttachmentDisplay.extend(/** @lends wp.media.view.MediaDetails.pr
this.$( '.embed-media-settings' ).scrollTop( 0 );
}
},/** @lends wp.media.view.MediaDetails */{
instances : 0,
/**
* When multiple players in the DOM contain the same src, things get weird.
* Formerly appended a cache-busting query arg to each media source.
*
* @param {HTMLElement} elem The HTML element containing the media sources to be prepared.
* @return {HTMLElement} The prepared element.
* @deprecated 7.3.0 Returns the element unchanged.
*
* @param {HTMLElement} elem The HTML element containing the media sources.
* @return {HTMLElement} The unchanged element.
*/
prepareSrc : function( elem ) {
var i = MediaDetails.instances++;
_.each( $( elem ).find( 'source' ), function( source ) {
source.src = [
source.src,
source.src.indexOf('?') > -1 ? '&' : '?',
'_=',
i
].join('');
} );

return elem;
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/js/media/views/video-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ VideoDetails = MediaDetails.extend(/** @lends wp.media.view.VideoDetails.prototy
}

if ( ! video.hasClass( 'youtube-video' ) && ! video.hasClass( 'vimeo-video' ) ) {
this.media = MediaDetails.prepareSrc( video.get(0) );
this.media = video.get(0);
} else {
this.media = video.get(0);
}
Expand Down
6 changes: 2 additions & 4 deletions src/wp-includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -3683,8 +3683,7 @@ function wp_audio_shortcode( $attr, $content = '' ) {
}

$type = wp_check_filetype( $atts[ $fallback ], wp_get_mime_types() );
$url = add_query_arg( '_', $instance, $atts[ $fallback ] );
$html .= sprintf( $source, $type['type'], esc_url( $url ) );
$html .= sprintf( $source, $type['type'], esc_url( $atts[ $fallback ] ) );
}
}

Expand Down Expand Up @@ -3966,8 +3965,7 @@ function wp_video_shortcode( $attr, $content = '' ) {
} else {
$type = wp_check_filetype( $atts[ $fallback ], wp_get_mime_types() );
}
$url = add_query_arg( '_', $instance, $atts[ $fallback ] );
$html .= sprintf( $source, $type['type'], esc_url( $url ) );
$html .= sprintf( $source, $type['type'], esc_url( $atts[ $fallback ] ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ static function ( $html, $attr, $content, $id ) use ( &$instance ) {

$expected = '<div style="width: ' . $width . 'px;" class="wp-video">' .
'<video class="wp-video-shortcode" id="video-' . $post_id . '-' . $instance . '" width="' . $width . '" height="' . $h . '" preload="metadata" controls="controls">' .
'<source type="video/mp4" src="http://domain.tld/wp-content/uploads/2013/12/xyz.mp4?_=' . $instance . '" />' .
'<source type="video/mp4" src="http://domain.tld/wp-content/uploads/2013/12/xyz.mp4" />' .
'<!-- WebM/VP8 for Firefox4, Opera, and Chrome --><source type="video/webm" src="myvideo.webm" />' .
'<!-- Ogg/Vorbis for older Firefox and Opera versions --><source type="video/ogg" src="myvideo.ogv" />' .
'<!-- Optional: Add subtitles for each language --><track kind="subtitles" src="subtitles.srt" srclang="en" />' .
Expand Down
Loading