Okay
  Print

[StreamTube] Upload/Embed Video

You can add videos in two different ways:

Backend Form


  1. Click the Videos tab.
  2. Click the Add New sub-tab.
  3. Start filling in the blanks: enter your post title in the upper field, and enter your post body content in the main post editing box below it.
  4. In the Main Video Source metabox, click the "Upload a file" button to choose your video file or paste a video URL, iframe, or script code into the Media ID textarea field. You can also fill in the video length and aspect ratio fields.
  5. As needed, select a category, add tags, and make other selections from the sections below the post.
  6. Also, you can upload or embed a video trailer from the section.
  7. When you are ready, click Publish.

Read more about the WordPress Writing Posts

Frontend Form


To allow Frontend posting, navigate to Appearance > Customize > Theme Options > Upload section and check on Upload Videos and Embed Videos checkboxes, you can allow which type of video you want, these two checkboxes are checked by default.

After enabling the feature, you will be able to add videos at frontend

Upload Big Files https://phpface.ticksy.com/article/19949/

To have full permission for adding videos as well as managing videos, the members have to be an Author or higher role. The contributors and subscribers roles cannot add videos for a number of reasons.

Custom roles need to have the same capabilities as the Author role to be able to upload and embed videos.

  • delete_posts
  • delete_published_posts
  • edit_posts
  • edit_published_posts
  • publish_posts
  • read
  • upload_files

Regular authors must have the "unfiltered_html" capability to embed code.

Read more about User Roles and Capabilities for further information https://wordpress.org/documentation/article/roles-and-capabilities/#author


Display oEmbed Source (Credits)

Embedding videos from YouTube and other video platforms without properly attributing the source may lead to search engine penalties. To ensure compliance and avoid potential penalties, it's recommended to add the following code snippet to the end of the 'functions.php' file located in 'wp-content/themes/streamtube-child/'. This code snippet will properly display the source of embedded videos.

/**
 * Display oembed content as credits
 */
function streamtube_child_display_oembed_content( $content ) {
    $maybe_oembed_url = get_post_meta( get_the_ID(), 'video_url', true );
    if ( ! $maybe_oembed_url || ! wp_http_validate_url( $maybe_oembed_url ) ) {
        return $content;
    }
    $oembed         = new WP_oEmbed();
    $oembed_content = (array) $oembed->get_data( $maybe_oembed_url );
    if ( $oembed_content ) {
        $source = '';
        $source .= sprintf(
            '<li><strong>%1$s</strong> <a target="_blank" href="%2$s">%2$s</a></li>',
            esc_html__( 'Source', 'streamtube-child' ),
            $maybe_oembed_url
        );
        if ( array_key_exists( 'author_url', $oembed_content ) && $oembed_content['author_url'] ) {
            $source .= sprintf(
                '<li><strong>%1$s</strong> <a target="_blank" href="%2$s">%2$s</a></li>',
                esc_html__( 'Channel', 'streamtube-child' ),
                esc_url( $oembed_content['author_url'] )
            );
        }
        $content .= sprintf( '<ul class="list-unstyled">%s</ul>', $source );
    }
    return $content;
}
add_filter( 'the_content', 'streamtube_child_display_oembed_content' );