wp_get_video_extensions example



    switch ( $type ) {
        case 'image':
            $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp' );
            return in_array( $ext$image_exts, true );

        case 'audio':
            return in_array( $extwp_get_audio_extensions(), true );

        case 'video':
            return in_array( $extwp_get_video_extensions(), true );

        default:
            return $type === $ext;
    }
}

/** * Determines whether an attachment is an image. * * For more information on this and similar theme functions, check out * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ * Conditional Tags} article in the Theme Developer Handbook. * * @since 2.1.0 * @since 4.2.0 Modified into wrapper for wp_attachment_is() and * allowed WP_Post object to be passed. * * @param int|WP_Post $post Optional. Attachment ID or object. Default is global $post. * @return bool Whether the attachment is an image. */

    wp_embed_register_handler( 'audio', '#^https?://.+?\.(' . implode( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 );

    /** * Filters the video embed handler callback. * * @since 3.6.0 * * @param callable $handler Video embed handler callback function. */
    wp_embed_register_handler( 'video', '#^https?://.+?\.(' . implode( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 );
}

/** * YouTube iframe embed handler callback. * * Catches YouTube iframe embed URLs that are not parsable by oEmbed but can be translated into a URL that is. * * @since 4.0.0 * * @global WP_Embed $wp_embed * * @param array $matches The RegEx matches from the provided regex when calling * wp_embed_register_handler(). * @param array $attr Embed attributes. * @param string $url The original URL that was matched by the regex. * @param array $rawattr The original unmodified attributes. * @return string The embed HTML. */
'replace_media'              => _x( 'Replace Video', 'label for button in the video widget; should preferably not be longer than ~13 characters long' ),
                'edit_media'                 => _x( 'Edit Video', 'label for button in the video widget; should preferably not be longer than ~13 characters long' ),
                'missing_attachment'         => sprintf(
                    /* translators: %s: URL to media library. */
                    __( 'That video cannot be found. Check your <a href="%s">media library</a> and make sure it was not deleted.' ),
                    esc_url( admin_url( 'upload.php' ) )
                ),
                /* translators: %d: Widget count. */
                'media_library_state_multi'  => _n_noop( 'Video Widget (%d)', 'Video Widget (%d)' ),
                'media_library_state_single' => __( 'Video Widget' ),
                /* translators: %s: A list of valid video file extensions. */
                'unsupported_file_type'      => sprintf( __( 'Sorry, the video at the supplied URL cannot be loaded. Please check that the URL is for a supported video file (%s) or stream (e.g. YouTube and Vimeo).' ), '<code>.' . implode( '</code>, <code>.', wp_get_video_extensions() ) . '</code>' ),
            )
        );
    }

    /** * Get schema for properties of a widget instance (item). * * @since 4.8.0 * * @see WP_REST_Controller::get_item_schema() * @see WP_REST_Controller::get_additional_fields() * @link https://core.trac.wordpress.org/ticket/35574 * * @return array Schema for properties. */
'ppt',
        'odt',
        'pptx',
        'docx',
        'pps',
        'ppsx',
        'xls',
        'xlsx',
        'key',
    );
    $audio_exts       = wp_get_audio_extensions();
    $video_exts       = wp_get_video_extensions();
    $upload_filetypes = array_unique( array_merge( $misc_exts$audio_exts$video_exts ) );

    $sitemeta = array(
        'site_name'                   => __( 'My Network' ),
        'admin_email'                 => $email,
        'admin_user_id'               => $site_user->ID,
        'registration'                => 'none',
        'upload_filetypes'            => implode( ' ', $upload_filetypes ),
        'blog_upload_space'           => 100,
        'fileupload_maxk'             => 1500,
        'site_admins'                 => $site_admins,
        

    $override = apply_filters( 'wp_video_shortcode_override', '', $attr$content$instance );

    if ( '' !== $override ) {
        return $override;
    }

    $video = null;

    $default_types = wp_get_video_extensions();
    $defaults_atts = array(
        'src'      => '',
        'poster'   => '',
        'loop'     => '',
        'autoplay' => '',
        'muted'    => 'false',
        'preload'  => 'metadata',
        'width'    => 640,
        'height'   => 360,
        'class'    => 'wp-video-shortcode',
    );

    
</audio> <?php }

/** * Outputs the markup for a video tag to be used in an Underscore template * when data.model is passed. * * @since 3.9.0 */
function wp_underscore_video_template() {
    $video_types = wp_get_video_extensions();
    ?> <# var w_rule = '', classes = [], w, h, settings = wp.media.view.settings, isYouTube = isVimeo = false; if ( ! _.isEmpty( data.model.src ) ) { isYouTube = data.model.src.match(/youtube|youtu\.be/); isVimeo = -1 !== data.model.src.indexOf('vimeo'); } if ( settings.contentWidth && data.model.width >= settings.contentWidth ) { w = settings.contentWidth; } else { w = data.model.width; } if ( w !== data.model.width ) { h = Math.ceil( ( data.model.height * w ) / data.model.width ); } else { h = data.model.height; } if ( w ) { w_rule = 'width: ' + w + 'px; '; } if ( isYouTube ) { classes.push( 'youtube-video' ); } if ( isVimeo ) { classes.push( 'vimeo-video' ); } #> <div style="{{ w_rule }}" class="wp-video"> <video controls class="wp-video-shortcode {{ classes.join( ' ' ) }}" <# if ( w ) { #>width="{{ w }}"<# } #> <# if ( h ) { #>height="{{ h }}"<# } #>
Home | Imprint | This part of the site doesn't use cookies.