WordPress.org

Ready to get started?Download WordPress

Forums

Custom homepage thumbnail size? (9 posts)

  1. welshhuw
    Member
    Posted 4 years ago #

    Hi,

    I have installed the post thumbnail into my latest wordpress system.
    And it works fine - the image displays on the homepage as requested.
    One issue tho, is that i cannot get it to be 300x600px in size. It only seems to go to 300x300??

    Please can someone help me solve this.

    PS. The site is on local machine at the moment.

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Try adding:

    if ( function_exists( 'set_post_thumbnail_size' ) ) {
    	set_post_thumbnail_size(300, 600, true ); // hard crop, fixed, mode
    }

    to your theme's functions.php file.

  3. welshhuw
    Member
    Posted 4 years ago #

    Hi,
    I have that exact coding.
    Im trying to get my image to display at 564x206px.
    It displays at 206 high, but only about 300px wide??

    And i have this in my index.php:
    <a href="<?php the_permalink() ?>"<?php the_post_thumbnail(array( 564, 206, true ), array( 'class' => 'alignleft' )); ?></a>

    Help!!

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    In functions.php, try:

    if ( function_exists( 'set_post_thumbnail_size' ) ) {
    	set_post_thumbnail_size(300, 600, true ); // hard fixed/crop mode
    }
    if ( function_exists( 'add_image_size' ) ) {
    	add_image_size( 'index-post-thumbnail', 564, 206, true ); //
    }

    Then, in index.php use:

    <a href="<?php the_permalink() ?>"<?php the_post_thumbnail('index-post-thumbnail'); ?></a>

  5. welshhuw
    Member
    Posted 4 years ago #

    Still didn't work??
    This is weird.

    functions.php:

    add_theme_support('post-thumbnails');
    if ( function_exists( 'set_post_thumbnail_size' ) ) {
    	set_post_thumbnail_size(564, 206, true ); // box (proportional) resize mode
    }

    index.php:

    <div class="img-holder">
    <div class="post-img">
    <a href="<?php the_permalink() ?>"<?php the_post_thumbnail(array( 564, 206, true ), array( 'class' => 'alignleft' )); ?></a>
    </div>
    </div>

    CSS:

    .img-holder {
    		width:600px;
    		height:245px;
    		background:url("img/img-holder.gif") no-repeat;
    	}
    
    		.post-img {
    			/*background:#000;*/
    			width:564px;
    			height:206px;
    			position:relative;
    			top:14px;
    			left:15px;
    		}
  6. welshhuw
    Member
    Posted 4 years ago #

    The other issue is that the images don't appear in IE7/8 or Opera??

  7. cooperanet
    Member
    Posted 4 years ago #

    I have the same problem.

    Sadly, the hard crop mode seems not to function.

    Example:

    in my functions.php file

    add_image_size( 'new_thumbnail_size', 300, 100, true );

    in my theme file (ex. single.php)
    if ( has_post_thumbnail() ) { the_post_thumbnail( 'new_thumbnail_size' ); }

    The image is not cropped as wanted. The height is good but the width stays proportionnal to the height, so in my case, the width is less than 300 pixels.

    Weird, weird, weird. I also use version 2.9.1. Maybe the 2.9.2 fixed the bug?

  8. welshhuw
    Member
    Posted 4 years ago #

  9. stylishbeachbum
    Member
    Posted 4 years ago #

    HI Welshhuw,

    Are you saying that you followed Mark's instructions and got the hard crop to work?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.