• I am working on a site that uses multiple post thumbnails. The thumbnail size for single posts is 306×306. Some of the thumbnails are too small and I want to force the size. Here is the code that pulls in the thumbnails:

    <div class="content-image">
                            	<?php if ( class_exists('MultiPostThumbnails')){ ?>
    
                                <div class="img">
                                  <?php
                                        for( $i=1; $i<=5 ; $i++ )
                                        {
                                            $image_id = 'featured-image-'.$i;
                                            $image_url = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(),$image_id );
    										echo $thumb_id = MultiPostThumbnails::get_post_thumbnail_id(get_post_type(),$image_id,$post->ID);
    
                                            if( $image_url != '' )
                                            {
                                 ?>
                                                <a class="lightbox" href="<?php echo $image_url;?>" style="position: absolute; top: 0px; left: 0px; display: none; z-index: 5; opacity: 0; width: 306px; height: 306px;">
                                                    <span><img width="306" height="306" alt="" src="<?php echo $image_url;?>"></span>
                                                    <div class="sprite"></div>
                                                </a>
                                <?php
                                            }
                                            else
                                            {
                                              break;
                                            }
                                        }
                                ?>
    
                                </div>

    There are two places where image size is mentioned but I can’t figure out how to force the scaling.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    The first size parameters are for styling the link that works when the image is clicked. The second set controls the size of the image itself. Browsers typically scale images to match the specified parameters without needing to be forced, they just do it. At least mine (Firefox) does. I’m not aware of any HTML attribute that forces the browser to scale an image, since it is supposed to anyway.

    Thread Starter creativeliza

    (@creativeliza)

    hmmm too bad. I use Firefox too and it doesn’t work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple Post Thumbnails force size’ is closed to new replies.