wp_oembed_get example


        $attr['discover'] = apply_filters( 'embed_oembed_discover', true );

        // Use oEmbed to get the HTML.         $html = wp_oembed_get( $url$attr );

        if ( $post_id ) {
            if ( $html ) {
                update_post_meta( $post_id$cachekey$html );
                update_post_meta( $post_id$cachekey_timetime() );
            } elseif ( ! $cache ) {
                update_post_meta( $post_id$cachekey, '{{unknown}}' );
            }
        } else {
            $has_kses = false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' );

            
echo wp_video_shortcode(
                array_merge(
                    $instance,
                    compact( 'src' )
                ),
                $instance['content']
            );

            remove_filter( 'wp_video_shortcode', array( $this, 'inject_video_max_width_style' ) );
        } else {
            echo $this->inject_video_max_width_style( wp_oembed_get( $src ) );
        }
    }

    /** * Inject max-width and remove height for videos too constrained to fit inside sidebars on frontend. * * @since 4.8.0 * * @param string $html Video shortcode HTML output. * @return string HTML Output. */
    
Home | Imprint | This part of the site doesn't use cookies.