$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>shortcode - Video Short Code and Media Fragments URI|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

shortcode - Video Short Code and Media Fragments URI

matteradmin9PV0评论

It looks like Wordpress video short code does not support media fragments URI (.e.g. appending #t=10 for the video src for example), so something like this wont work:

[video width="854" height="480" src=".mp4#t=18" preload="metadata"][/video]

because adding #t=18 at the end of the video confuses the video tag to recognize it's a video. How can I solve this, other than using a traditional html video tag, is there a patch for wp_video_shortcode function for this to work, or any other workarounds?

Update #1

Problem specifically in this line wp-includes/media.php Line 2498 that outputs the video as just an anchor link:

    $type = wp_check_filetype( $atts['src'], wp_get_mime_types() );
    if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) {
        return sprintf( '<a class="wp-embedded-video" href="%s">%s</a>', esc_url( $atts['src'] ), esc_html( $atts['src'] ) );
    }

It looks like Wordpress video short code does not support media fragments URI (.e.g. appending #t=10 for the video src for example), so something like this wont work:

[video width="854" height="480" src="https://www.domain/wp-content/uploads/2018/07/5898ca6e5276e4cd97c0bd730a2ed82c11780595-480p__80044.mp4#t=18" preload="metadata"][/video]

because adding #t=18 at the end of the video confuses the video tag to recognize it's a video. How can I solve this, other than using a traditional html video tag, is there a patch for wp_video_shortcode function for this to work, or any other workarounds?

Update #1

Problem specifically in this line wp-includes/media.php Line 2498 that outputs the video as just an anchor link:

    $type = wp_check_filetype( $atts['src'], wp_get_mime_types() );
    if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) {
        return sprintf( '<a class="wp-embedded-video" href="%s">%s</a>', esc_url( $atts['src'] ), esc_html( $atts['src'] ) );
    }
Share Improve this question edited Dec 1, 2018 at 18:05 Yehia A.Salam asked Dec 1, 2018 at 17:54 Yehia A.SalamYehia A.Salam 1012 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Try embedding your video like this:

<video controls>
  <source src="https://www.domain/wp-content/uploads/2018/07/5898ca6e5276e4cd97c0bd730a2ed82c11780595-480p__80044.mp4#t=18" type="video/mp4" />
</video>

Paste this in your editor but make sure on the top right it is set to "Text" not "Visual". When you switch it back to "Visual" you will just see blank gray frame. Preview the post and you should see the video embedded with the start time.

Note the controls tag, if you remove that then the video won't load and it will just show you a screenshot. So what you are doing is essentially writing your own html embed code.

You can also add other tags to the video such as width / height, autoplay, etc.

Hope this helped!

Post a comment

comment list (0)

  1. No comments so far