0

I am having issues getting some logos to display on my page. The page shows the search results for a series of companies, with each result shown in a small box. I need the logo to scale correctly to fit within this box, however currently it is only changing the height, which causes it to look stretched.

The code for the box is:

  •    <div class="membername"><?php the_title(); //echo the_excerpt(); ?></div>
          <a class="button" href="<?php the_permalink(); ?>" title="<?php the_title(); ?> Member Profile">View Details</a>
     </li>
    

    However, the code being output for the image is as follows:

    <img width="130" height="78" src="img.jpg" class="attachment-thumbnail wp-post-image">
    

    Which seems to be the problem. I need the image to display no higher than 34px, however if I set this size in CSS, the width remains the original 130 set in the html. All images are different sizes so I cannot hardcode the width.

    How can I go about scaling the image so it wont stretch?

    0

    There is a simple solution available in WordPress : add_image_size

    You can register as many sizes required in your theme, WordPress will generate the images in that size and crop it if crop is enable for that size.

    You can use regenerate thumbnails plugin to generate all the image sizes for older posts.

    Please check codex for more info.

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

    Not the answer you're looking for? Browse other questions tagged or ask your own question.