Skip to:
Content
Pages
Categories
Search
Top
Bottom

help me modifying the plugin


  • purityboy83
    Participant

    @purityboy83

    Hi

    I want the thumbnail to appear on the topic
    Search results found a plugin similar to the function I’m hoping for

    bbpress-topic-thumbnails
    https://wordpress.org/plugins/bbpress-topic-thumbnails/

    I want to add one more feature in this plugin.
    With this plugin, thumbnails of all forum topics are displayed

    I only want to use this feature for 1 specific forum
    reason for write topic is because the plugin has not been updated for a long time.

    So I ask for help here

    code is

    
    /*Hooks into the loop-topic.php output to print image*/
    add_action( 'bbp_theme_before_topic_title', 'bee_insert_thumbnail' );
    function bee_insert_thumbnail() {
    
            if((!bee_catch_image() == '')){
            echo('<a href="'); 
        echo(bbp_topic_permalink() . '"><img class="bbp-topic-thumbnail"  width="100%" style="max-width: ' . get_option('thumbnail_size_w') . 'px; max-height: ' . get_option('thumbnail_size_h'). 'px; vertical-align:middle;" src="' . bee_catch_image() . '"/>' .'</a>');
            }
    }
    
    /*Function that retrieves the first image associated with the topic*/
    function bee_catch_image() {
      global $post, $posts;
      $first_img = '';
      ob_start();
      ob_end_clean();
      $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
      $first_img = $matches [1] [0];
      return $first_img;
    }
    

    Anyone can help?
    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar