- This topic has 7 replies, 2 voices, and was last updated 5 years ago by Tom.
-
AuthorPosts
-
April 18, 2019 at 9:11 am #872781Charlie
Howdy howdy!
I’m trying to force crop my images to fit a 1200×500 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!
April 18, 2019 at 4:11 pm #873046TomLead DeveloperLead DeveloperHmm, 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?
April 18, 2019 at 5:29 pm #873072CharlieHey 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!
April 19, 2019 at 8:30 am #873600TomLead DeveloperLead DeveloperThat sounds like the previous thumbnails weren’t regenerated. Which plugin did you use to regenerate?
April 19, 2019 at 8:38 am #873607CharlieDon’t want to link to it if that’s disallowed here, but I used the one called Regenerate Thumbnails by Alex Mills (Viper007Bond).
April 19, 2019 at 9:17 am #873646TomLead DeveloperLead DeveloperThat’s the good one, it should definitely work. Maybe try regenerating again? Does it show any errors?
April 19, 2019 at 11:20 am #873717CharlieAppreciate 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.
April 19, 2019 at 6:28 pm #873895TomLead DeveloperLead DeveloperAlways happy to help 🙂 Thank you!
-
AuthorPosts
- You must be logged in to reply to this topic.