Previously, attempting to render an SVG image through an image style would produce errors. You could do something like this:
$element = [
'#theme' => 'image_style',
'#uri' => 'public://some-svg-image.svg',
'#style_name' => 'large',
'#alt' => 'foobar',
];
echo (string) drupal_render_root($element);
This would produce an <img> tag like this:
<img src="/sites/default/files/styles/large/public/some-svg-image.svg?itok=3EuqMoBS" alt="foo" typeof="foaf:Image" class="image-style-large" />
This tag would produce a "broken image" icon, and the generated URL would produce a response with the words "Error generating image." Additionally, an error like this would be logged by Drupal: "Unable to generate the derived image located at public://styles/large/public/Druplicon.vector.svg." This was due to the image style toolkit not knowing how to handle SVG images.
Image styles now fail more gracefully with SVG and other unsupported formats. If the style does not support the image format, it will simply set the image's #access property to FALSE, which by default will produce no markup at all. Meanwhile, a warning like this will be logged by Drupal: "Could not apply Large image style public://some-svg-image.svg because the style does not support it."
This gives you a little wiggle room -- if you would like to display the image anyway, you can implement a preprocess function in your module or theme to restore access to the image:
function mytheme_preprocess_image_style(array &$variables) {
if (pathinfo($variables['uri'], PATHINFO_EXTENSION) == 'svg' && $variables['image']['#access'] == FALSE) {
$variables['image']['#alt'] = 'My fallback SVG image.';
$variables['image']['#uri'] = 'public://fallback-svg-image.svg';
$variables['image']['#access'] = TRUE;
}
}