Skipping SVG when regenerating images
-
When regenerating images the SVG files do not get excluded thus causing an error which is not clear why.
$ wp media regenerate 232 Found 1 image to regenerate. Warning: 1/1 Couldn't regenerate thumbnails for "stylelint" (ID 232). Error: No images regenerated.By adding a bit of extra code it can be made clear why a certain file is not being processed.
add_filter( 'wp_generate_attachment_metadata', function( $metadata, $attachment_id ) { if ( 'image/svg+xml' === get_post_mime_type( $attachment_id ) ) { return new WP_Error( 'skip_svg_generate', __( 'Skipping SVG files.', 'textdomain' ) ); } return $metadata; }, 10, 2 );When running the regenerate script the information would be clearer.
$ wp media regenerate 232 Found 1 image to regenerate. Warning: Skipping SVG files. Error: No images regenerated.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Skipping SVG when regenerating images’ is closed to new replies.