SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2013
    Location
    Philippines
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Fixing the width and height of the post thumbnail

    I'm having trouble trying to set the width and height of my post thumbnail.


    Here is the link for the image

    http://i255.photobucket.com/albums/h...psbe1027f9.png


    As you can see both of the post have different dimensions

    I have tried a couple of times in fixing the height and width of my post in fuction.php but no luck. Basically what i want to accomplish is that if i upload an image in the featured image regardless of size it would come out with a height of 250px and a width of 250 px. But whatever i do it seems incorrect.

    This is the code that i have encoded

    index.php

    <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?>


    functions.php

    //post thumbnail support 3

    add_theme_support( 'post-thumbnails', array( 'post' ) );
    set_post_thumbnail_size( 250, 250 );

    Am i missing something? I'm still trying to code in wordpress and PHP language. Basically i'm still a newbie. I really want to accomplish this without having to really on plugins

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,097
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    You can set the width and height either in the HTML and/or in the CSS.

    HTML:

    Code:
    <img src="" width="250" height="250" alt="">
    CSS:

    Code:
    .post img {width: 250px; height: 250px;}
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •