function wpc_fix_svg_size_attributes($out, $id) { $image_url = wp_get_attachment_url($id); $file_ext = pathinfo($image_url, PATHINFO_EXTENSION); if (is_admin() || 'svg' !== $file_ext) { return false; } return array($image_url, null, null, false); } add_filter('image_downsize', 'wpc_fix_svg_size_attributes', 10, 2);
// into any page or template <?php $image = get_field('image'); if( !empty( $image ) ): ?> <img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" /> <?php endif; ?>
// into functions.php <?php function sp_enable_svg_upload( $mimes ) { //For security reasons only admin can uplaod svg files if ( !current_user_can( 'administrator' ) ) { return $mimes; } $mimes['svg'] = 'image/svg+xml'; $mimes['svgz'] = 'image/svg+xml'; return $mimes; } add_filter('upload_mimes', 'sp_enable_svg_upload'); ?>
Or use Daryll Doyle Safe SVG plugin.
// functions.php add_filter( 'jpeg_quality', function( $arg ) { return 100; });
// functions.php add_image_size( 'sp_cover', 1980, 1200, true ); add_filter( 'image_size_names_choose', 'sp_custom_image_sizes' ); function sp_custom_image_sizes( $sizes ) { return array_merge( $sizes, array( 'sp_cover' => __( 'Rosa cover' ), ) ); }
// functions.php add_theme_support( 'responsive-embeds' );