Forums

Video Thumbnails
Wordtube thumbnails (3 posts)

  1. islandcastaway
    Member
    Posted 1 year ago #

    I would love to see a hook to be able to grab out thumbnails from Wordtube.

    cheers

  2. Sutherland Boswell
    Member
    Posted 1 year ago #

    Hmmm... looking at the surface of wordTube I don't immediately know how to add support for it. At the moment my plugin uses methods provided by the video services to retrieve the thumbnail. I'll look into it some more and see if I figure something out.

  3. islandcastaway
    Member
    Posted 1 year ago #

    I came up with some code to get the image from wordtube:

    <?php //wordtube
        $content  = $post->post_content;
        $wordtubeshortcode = stripos($content, "[media");
        if($wordtubeshortcode !== false){
        $matches = array();
        $html = $post->post_content;
        $pattern = "/\[media id=(\d+)\]/";
        preg_match( $pattern, $html, $matches );
        $wordtubeId = $matches['1'];
        $wordtubeimage = $wpdb->get_var($wpdb->prepare("SELECT image FROM $wpdb->wordtube WHERE vid = $wordtubeId;"));
        echo '<img src="'.$wordtubeimage.'">';
            }?>

    It does not work with the legacy [media=#] or [media id=# width=# height=#]

    to use width and height use:

    $pattern = "/\[media id=(\d+)(?: width=)?(\d+)?(?: height=)?(\d+)?\]/";

    Hopefully someone can improve on this.

    Cheers

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic