Site logo

Archived topic

Force Crop Blog Page Images

7 replies · Started by Charlie on April 18, 2019

Viewing posts 1–8 of 8

Howdy howdy!

I'm trying to force crop my images to fit a 1200x500 proportions for my main blog page (and archives). I am using this code:

add_action('after_setup_theme', 'tu_add_image_sizes');
function tu_add_image_sizes() {
    add_image_size( 'large-thumbnail', 1200, 500, true ); // (cropped)
    add_filter( 'generate_page_header_default_size', 'tu_set_image_size' ); // (tell GP to use this size for index pages)
}

function tu_set_image_size() {
    return 'large-thumbnail';
}

Which I got from this forum post: https://generatepress.com/forums/topic/custom-crop-for-blog-index-featured-images/#post-357876.

Doesn't seem to be working for me as you can see with the "Why taking small steps..." image in the URL I'll attach. Any ideas?

Oh by the way I have tried using the Regenerate Thumbnails plugin as well.

Thanks much!

Hmm, looks like it should work as long as thumbnails were regenerated.

If you upload a new image, is that image size created in your uploads folder?

Hey Tom! Thanks, mate.

This is really weird, but it seems to be working now even though I can't really explain why. I tried it twice just now, once by re-uploading the same featured image that wasn't working. It continued not working. Hmph.

Then I uploaded a brand new, entirely different featured image and that was cropped perfectly fine. I have no idea why this would be, but maybe it's sorted? Don't want to bug you if I can just ignore the problem, but I'd definitely be curious why it's acting the way it is.

Cheers!

That sounds like the previous thumbnails weren't regenerated. Which plugin did you use to regenerate?

Don't want to link to it if that's disallowed here, but I used the one called Regenerate Thumbnails by Alex Mills (Viper007Bond).

That's the good one, it should definitely work. Maybe try regenerating again? Does it show any errors?

Appreciate it, Tom. I think I might just chalk this up to a faulty/buggy xml import. Everything's working as it should now. New featured images come in and crop just fine.

GP is amazingly stable so I rarely need your support, but when I do you guys are always the epitome of great service. Really appreciate it.

Always happy to help :) Thank you!

This archived topic is closed to new replies.