• I have put together some code for this plugin to also get the image from wordTube video posts:

    added after line 104:
    
    $content = $r->post_content;
    $wordtubeshortcode = stripos($content, "[media");
    
    added after the stripos <img routine line 130ish:
    
    if($wordtubeshortcode !== false){
      $html = $r->post_content;
      $matches = array();
      $pattern = "/\[media id=(\d+)\]/";
      preg_match( $pattern, $html, $matches );
      $wordtubeId = $matches['1'];
      $image = $wpdb->get_var($wpdb->prepare("SELECT image FROM $wpdb->wordtube WHERE vid = $wordtubeId;"));
    }

    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

    https://www.ads-software.com/extend/plugins/best-related-posts/

  • The topic ‘[Plugin: Best Related Posts] wordTube images’ is closed to new replies.