[Resolved] Force Crop Blog Page Images

Home Forums Support [Resolved] Force Crop Blog Page Images

Home Forums Support Force Crop Blog Page Images

  • This topic has 7 replies, 2 voices, and was last updated 5 years ago by Tom.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #872781
    Charlie

    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!

    #873046
    Tom
    Lead Developer
    Lead Developer

    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?

    #873072
    Charlie

    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!

    #873600
    Tom
    Lead Developer
    Lead Developer

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

    #873607
    Charlie

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

    #873646
    Tom
    Lead Developer
    Lead Developer

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

    #873717
    Charlie

    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.

    #873895
    Tom
    Lead Developer
    Lead Developer

    Always happy to help 🙂 Thank you!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.