summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/shortcodes/vimeo.php')
-rw-r--r--plugins/jetpack/modules/shortcodes/vimeo.php22
1 files changed, 17 insertions, 5 deletions
diff --git a/plugins/jetpack/modules/shortcodes/vimeo.php b/plugins/jetpack/modules/shortcodes/vimeo.php
index f05965ea..b1090833 100644
--- a/plugins/jetpack/modules/shortcodes/vimeo.php
+++ b/plugins/jetpack/modules/shortcodes/vimeo.php
@@ -11,7 +11,7 @@
*
* <iframe src="http://player.vimeo.com/video/18427511" width="400" height="225" frameborder="0"></iframe><p><a href="http://vimeo.com/18427511">Eskmo 'We Got More' (Official Video)</a> from <a href="http://vimeo.com/ninjatune">Ninja Tune</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
*
- * @package Jetpack
+ * @package automattic/jetpack
*/
/**
@@ -258,19 +258,31 @@ add_shortcode( 'vimeo', 'vimeo_shortcode' );
* @return string Return output of Vimeo shortcode with the proper markup.
*/
function wpcom_vimeo_embed_url( $matches, $attr, $url ) {
- return vimeo_shortcode( array( $url ) );
+ $vimeo_info = array( $url );
+
+ // If we are able to extract a video ID, use it in the shortcode instead of the full URL.
+ if ( ! empty( $matches['video_id'] ) ) {
+ $vimeo_info = array( 'id' => $matches['video_id'] );
+ }
+
+ return vimeo_shortcode( $vimeo_info );
}
/**
- * For bare URLs on their own line of the form
- * http://vimeo.com/12345
+ * For bare URLs on their own line of the form.
+ *
+ * Accepted formats:
+ * https://vimeo.com/289091934/cd1f466bcc
+ * https://vimeo.com/album/2838732/video/6342264
+ * https://vimeo.com/6342264
+ * http://player.vimeo.com/video/18427511
*
* @since 3.9
*
* @uses wpcom_vimeo_embed_url
*/
function wpcom_vimeo_embed_url_init() {
- wp_embed_register_handler( 'wpcom_vimeo_embed_url', '#https?://(.+\.)?vimeo\.com/#i', 'wpcom_vimeo_embed_url' );
+ wp_embed_register_handler( 'wpcom_vimeo_embed_url', '#https?://(?:[^/]+\.)?vimeo\.com/(?:album/(?<album_id>\d+)/)?(?:video/)?(?<video_id>\d+)(?:/.*)?$#i', 'wpcom_vimeo_embed_url' );
}
/*