• I installed the Best Related Posts plugin with thumbnails but find that sometimes the plugin uses images that do not translate well. And they are not resized either. I’d like to use the same cropped/resized thumbnail as is used for my category archives listings. Here is the code for that I believe:

    <a class="attachmentarchives" href="<?php the_permalink(); ?>"><?php fs_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"'); ?></a>

    How would I incorporate that into the Best Related Posts plugin code below?:

    /**
     * Outputs the HTML code with the related posts list.
     */
    function boposts_show()
    {
        global $wpdb, $post, $boposts_options;
    
        $results = boposts_find_posts();
        if (!$results) {
            echo 'No results';
            return;
        }
    
        echo $boposts_options['header'];
        $c = count($results);
        for ($i=0; $i<$c; $i++)
        {
            $r = &$results[$i];
            $p = get_post($r->id);
            $t = get_the_title($r->id);
            $excerpt = $r->post_content;
            $l = get_permalink($r->id);
    
            $content = $r->post_content;
            // Remove the short codes
            $content = preg_replace('/\[.*\]/', '', $content);
            // Image extraction
            $image = '';
            $x = stripos($content, '<img');
    
            if ($x !== false) {
                $x = stripos($content, 'src="', $x);
                if ($x !== false) {
                    $x += 5;
                    $y = strpos($content, '"', $x);
                    $image = substr($content, $x, $y-$x);
                }
            }
    
            if ($image == '') $image = get_option('siteurl') . '/wp-content/plugins/best-related-posts/empty.gif';
    
            // Excerpt extraction
            $excerpt = strip_tags($content);
            if (strlen($excerpt) > $boposts_options['excerpt'])
            {
                $x = strpos($excerpt, ' ', $boposts_options['excerpt']);
                if ($x !== false) $excerpt = substr($excerpt, 0, $x);
            }
            $s = $boposts_options['body'];
            $s = str_replace('{link}', $l, $s);
            $s = str_replace('{title}', $t, $s);
            $s = str_replace('{image}', $image, $s);
            $s = str_replace('{excerpt}', $excerpt . '...', $s);
    
            echo $s;
        }
        echo $boposts_options['footer'];
        echo '<div align="right"><small></small></div>';
    }
    
    add_action('admin_menu', 'boposts_admin_menu');
    register_activation_hook(__FILE__, 'boposts_activate');
    register_deactivation_hook(__FILE__, 'boposts_deactivate');
    
    ?>

    Many thanks for any help you can give!!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Best Related Posts plugin – choosing thumbnails used’ is closed to new replies.