• This is the last problem before I finish our site!
    The theme uses a posts featured image in both a slider and in the loop. The two instances require different sizes (not the same aspect ratio). I can get one working by uploading images of the right size, but then the other appears stretched, and visa versa.

    Help would be wonderful!

    Here are the relevant bits of code:

    Theme functions:

    function sight_setup() {
    	update_option('thumbnail_size_w', 290);
        update_option('thumbnail_size_h', 290);
        add_image_size( 'mini-thumbnail', 50, 50, true );
        add_image_size( 'slide', 640, auto, true );
        register_nav_menu('Navigation', __('Navigation'));
        register_nav_menu('Top menu', __('Top menu'));
    }

    loop code:

    <div <?php post_class('post clear'); ?> id="post_<?php the_ID(); ?>">
                <?php if ( has_post_thumbnail() ) :?>
                <a href="<?php the_permalink() ?>" class="thumb"><?php the_post_thumbnail('thumbnail', array(
                            'alt'	=> trim(strip_tags( $post->post_title )),
                            'title'	=> trim(strip_tags( $post->post_title )),
                        )); ?></a>
                <?php endif; ?>

    slideshow code:

    <?php if ( has_post_thumbnail() ) echo '<a href="'.get_permalink().'">'.get_the_post_thumbnail($post->ID, 'slide',
                        array(
                            'alt'	=> trim(strip_tags( $post->post_title )),
                            'title'	=> trim(strip_tags( $post->post_title )),
                        )).'</a>'; ?>
                    <div class="post-category"><?php the_category(' / '); ?></div>

    I considered using a plugin that allows multiple featured images, but can’t seem to integrate/adapt these into the loop or slideshow code.

    For example the Multiple Featured Images plugin with the following code in Functions.php:

    if( class_exists( 'kdMultipleFeaturedImages' ) ) {
    
            $args = array(
                    'id' => 'featured-image-2',
                    'post_type' => 'post',      // Set this to post or page
                    'labels' => array(
                        'name'      => 'Featured image 2',
                        'set'       => 'Set featured image 2',
                        'remove'    => 'Remove featured image 2',
                        'use'       => 'Use as featured image 2',
                    )
            );
    
            new kdMultipleFeaturedImages( $args );
    }

    Hope somebody out there can help!
    Kaspar
    PS. Our work in progress is here: https://stuttg-arttours.de/ (currently stretching the square thumbnails used in the loop)

    [No bumping. If it’s that urgent, consider hiring someone.]

  • The topic ‘Thumbnails with multiple uses – PLEASE HELP!’ is closed to new replies.