WordPress.org

Ready to get started?Download WordPress

Forums

Change Featured Image size ONLY on homepage (9 posts)

  1. meximelt
    Member
    Posted 2 years ago #

    I have a website with a theme that has Featured Images built in. I added a featured image to my post, but it is too big when it displays on my homepage.

    I already googled, but could not find a code snippet that worked just for reducing the homepage Featured Image for a post.

    Thanks

  2. meximelt
    Member
    Posted 2 years ago #

    Anyone?

  3. meximelt
    Member
    Posted 2 years ago #

    Bump

  4. keesiemeijer
    moderator
    Posted 2 years ago #

    review:
    http://codex.wordpress.org/Post_Thumbnails
    http://codex.wordpress.org/Function_Reference/add_image_size
    http://codex.wordpress.org/Conditional_Tags#The_Main_Page

    // in functions.php
    if ( function_exists( 'add_image_size' ) ) {
            // set image size here
    	add_image_size( 'homepage-thumb', 300, 9999 );
    }
    // in index.php (or whatever template file shows your front page)
    if(is_home()){
      if ( has_post_thumbnail() ) {
        the_post_thumbnail( 'homepage-thumb' );
      }
    }
  5. meximelt
    Member
    Posted 2 years ago #

    I did that and nothing has changed :(

  6. keesiemeijer
    moderator
    Posted 2 years ago #

    Sometimes you need to re-upload images before the new size is shown. You can also do this with a plugin: http://wordpress.org/extend/plugins/regenerate-thumbnails/

  7. meximelt
    Member
    Posted 2 years ago #

    We are getting somewhere!

    Added the plugin, regenerated images, and the latest posts image was added in the thumbnail format at the top right corner of the page, all by itself. The post's featured image on the homepage was not resized though.

    It doesnt change the post's featured image on homepage, just adds one small thumbnail is position depending where I post the code in Index.php

    I'll mess around a bit more, but any idea?

  8. meximelt
    Member
    Posted 2 years ago #

    Got it!

    I replaced the "archive-thumb" in the image.php file with "homepage-thumb", still having the add_image_size in the functions.php and it worked. Thanks for the Image Regenerator plugin, as I have to regenerate everytime I try and make the size right.

  9. Mey Samorn
    Member
    Posted 1 year ago #

    No plugin need, just add width:1004px; and i just found it! this is my site that come with build in featured slide. to change it go to style.css or css in your theme:

    under
    /* ={ FEATURED SLIDER - LARGE} */

    find

    #featured_a_posts .item .featured_media {border:1px solid #aaa;display:block;}

    change to

    #featured_a_posts .item .featured_media {width:1004px; border:1px solid #aaa;display:block;}

    Note: width:1004px for my site.
    thanks

Topic Closed

This topic has been closed to new replies.

About this Topic