Resize post thumbnail


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 );

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?


Fluxian 2 months 0 Answers 13 views 0

Leave an answer