• gomez77

    (@gomez77)


    Hello WordPress people,

    I am having a real problem with cropping my featured images to the size that I require.

    I have a static homepage that shows my three most recent posts.

    I have uploaded images for each post and their dimensions are 480 x 480 px. That is the size I want to display the images in the post. In the post excerpt on the homepage, I want the images to be cropped to 400 x 260 px.

    I have tried to achieve this using plugins like ‘Post Thumbnail Editor’ and ‘Crop Thumbnails’ but haven’t found a way to make this work. I have tried cropping both the ‘thumbnail’ and the ‘post-thumbnail’ but neither has any effect.

    I have also tried editing the functions.php file by adding the following code:

    add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 400, 260, true );

    I have spent hours on this but still the featured image in the excerpt on the homepage displays as a square image, 480 x 480 px.

    I would really appreciate any suggestions as to what I’m doing wrong.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter gomez77

    (@gomez77)

    Sorry, I wrote this question in a hurry this morning. I should have mentioned that I have the ‘Regenerate Thumbnails’ plugin and I run it each time I try to crop the images. I must have done it at least twenty times by now.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Does the code work with all plugins deactivated? If not, which theme are you using? How are you testing this code?

    Thread Starter gomez77

    (@gomez77)

    Thanks for your reply Andrew,

    I have tried deactivating all of my plugins but it doesn’t solve the problem.

    I am using the old Starkers theme, mainly because I want to create my own styles and simply because I don’t know any better.

    I have noticed this code in the function.php file:

    define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 400 ) );
    	define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 260 ) );

    I changed the values to 400 and 260 but this doesn’t help. I wondered if this code might have been conflicting with the set_post_thumbnail_size and tried commenting it out but that made no difference either.

    I have looked in the uploads folder for my website and the 400×260 images have been generated, they are just not being used.

    Thread Starter gomez77

    (@gomez77)

    Well, I seem to have solved this issue.

    I deleted all of the images for my posts and re-uploaded them and the thumbnails now appear at the desired size.

    This was not a problem as I am just building the website, so fortunately I only had three posts and three images. It might have been a bit annoying if it had been three hundred, for example.

    Thanks for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Cropping featured image’ is closed to new replies.