Site icon Hip-Hop Website Design and Development

All the time generate thumbnail after sideloading picture

I am sideloading a picture into wordpress from youtube. it really works advantageous and the important thing a part of the code is:

// sideload it into wordpress (generates varied sizes)
$thumbid = media_handle_sideload( $file_array, $post->ID );
if ( is_wp_error($thumbid) ) { // take care of error right here }

// kill present attachment first, if any
wp_delete_attachment(get_post_thumbnail_id($post->ID), true);

// and eventually affiliate submit with new thumbnail
set_post_thumbnail( $submit, $thumbid );

This is the issue. I’ve registered 5 picture sizes with add_image_size in my WordPress capabilities file. Once I sideload per the code above, WP generates all of the thumbs for the picture in all of the sizes besides one, 640×400. I consider it is skipping this thumb since 640×400 is definitely bigger than the picture that’s returned from YouTube. Nonetheless, I must get that thumbnail irrespective of what– I need to drive WordPress to generate that thumbnail. How can I try this?

I register the picture measurement identical to all others:

 add_image_size( 'static-head', 640, 400, true );

So I am on the lookout for operate kind of like wp_generate_thumbnail($thumbid, 'static-head'), that can depart the correct 640×400 picture within the uploads folder.

Thanks–