Custom Size Not Being Generated
-
Hello everyone, I’m developing a theme in WP 6.0.2. I tried to upload image by using wp_insert_attachment(). Then I want it to generate all the sub sizes.
$attachment_id = wp_insert_attachment([ 'guid' => $upload['url'], 'post_mime_type' => $upload['type'] ], $upload['file'] ); // Generate sub-sizes of the image. wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $upload['file'] ) );It works fine unless it doesn’t generate thumbnail with the custom size I defined, it only generates the thumbnail for WP default sizes.
function wing_theme_setup() { add_theme_support( 'post-thumbnails' ); add_image_size( 'other', 8, 8 ); } add_action( 'after_setup_theme', 'wing_theme_setup' );What should I do? Thanks in advance.
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
The topic ‘Custom Size Not Being Generated’ is closed to new replies.