Resize post thumbnail

Question

I’m trying to ensure that all assets are the same size, no matter what resolution they are uploaded in. I’m stuck finding outdated info on the matter, I think.

I’ve gotten to the follow snippet

if( get_the_post_thumbnail_url()){
    $image = wp_get_image_editor(get_the_post_thumbnail_url());
    if ( !is_wp_error( $image )){
        $image->resize( 300, 300, true );
        $image->save("image.jpg");
    }
}

Which seems to work, but I have no idea how I get the URL (or insert it properly).
Am I thinking about it wrong, or how should I continue from here?

Thanks!

0
Fluxian 2 months 0 Answers 13 views 0

Leave an answer