Problems with SVG images as Image Field
There are problems using SVG images as image fields:
1 - If the content type that contains an image field (not binary) is added to a container, then exceptions are logged to velocity log. We have also noticed that these exceptions are causing high CPU and memory usage and resulted in taking our site(s) down. The exception is being thrown by the containers call to #getContentByIdentifier and not by any velocity code in the container for loop. I have tracked it down to the call to VelocityWebUtil.mergeTemplate(String templatePath) Example trace is attached: velocity-error.txt velocity-error.txt
2- When an SVG image is selected for an image field it does not render correctly within the content edit view. (shows as a black square)
3 - When using the 'image picker' to browse for an image, the SVG images do not render correctly (shows as a missing image)
[Tested on dotCMS 3.2.3 and 3.3]
We need to insure that we support SVG images and that they render correctly
Confirmed by added SVG file for an "event" content type on the back-end of the demo site on 3.3.1 and checking the front-end's event detail page. Note: Preview is also broken on content edit page, and on browser preview from the "select image" pop-up.
Reference: https://my.dotcms.com/tickets/detail.dot?id=1d0ffea1-7f68-4820-82a3-ca483eb245f9 Test on: demo.dotcms.com (3.3.1)
@freddyucv for 2 and 3, you need to be looking here:
https://github.com/dotCMS/core/blob/master-3.5/dotCMS/html/js/dotcms/dijit/FileBrowserDialog.js#L403
While we are here, we should update this code and remove the call to the old thumbnail servlet and instead use the newer resizer, something like:
if(asset.mimeType != null && asset.mimeType.indexOf('image/') == 0 ){
if(asset.mimeType.indexOf('image/svg') <0 && asset.mimeType.indexOf('image/x-icon')<0){
assetThumbnail = '/contentAsset/image/' + asset.identifier + '/fileAsset/filter/Thumbnail/thumbnail_w/100/thumbnail_h/100/r/'+asset.inode;
}
else{
assetThumbnail= '/contentAsset/image/' + asset.identifier + '/fileAsset/'+asset.inode;
}
}
oops
@wezell OK, I was checking the ThumbnailImage Servlet just right know, I am going to check the BinaryExporterServlet instead then
@freddyucv The thumbnail servlet is dead - we should make a deprecated. We've replaced it with the /contentAsset/image/ servlet in most places, but this is one old piece of code.
@wezell ok
@scrossley , are you able to reproduce the first issue on demo.dotcms.com? We are not able to reproduce this issue and get the errors locally.
I am able to reproduce this on http://demo.dotcms.com. I have added an event to the top container (Large Column) on the homepage. This event has had an image added to the image field that is svg. Although the image is not shown by the container code, errors are logged to dotcms-velocity.log
@scrossley we are able to reproduce, thank you.
PR: https://github.com/dotCMS/core/pull/8947
master-3.5 PR: https://github.com/dotCMS/core/pull/8947 master-3.6 PR: https://github.com/dotCMS/core/pull/9016
We still having some problems with this type of images...
- Now we can see the image in preview mode, but we can't see the image thumbnail from the "Select file" window...

To recreate:
- Create a new content type with an image filed
- Create a new container and add the created content type
- Create a new template and add the created container
- Create a new page and select the created template
- Try to add a new content and upload some .svg image
Also we are having errors on log, when you save the content... https://gist.github.com/bryanboza/facc894f47f4a5e7f0ccc38bf2f04cc2
FYI: When you select the .svg file we are showing the image normally...
Tested on master-3.5 // MySQL // FF
Also we are unable to show this type of images in IE11... We are having a Broken pipe error on log
ERROR servlets.BinaryExporterServlet: java.io.IOException: Broken pipe
SC: http://screencast.com/t/BFARG6P72i
And here the localhost log: https://gist.github.com/bryanboza/eccc730f66de21240f5ccee8c2dd71c2
I'm able to see the .svg image correctly but when adding the image to a HTMLPage via an Image field I'm still getting the same errors in the logs.
Also able to recreate the broken pipe error in ie11.
Question, does the SVG file re-index properly - you will need an EE license to test.
Fixed, tested on master-3.5 // MySQL // FF
@bryanboza we tested the re-index? https://github.com/dotCMS/core/issues/8551#issuecomment-220643878
Yes, I tested with license and without it, and in both cases woks as expected... No errors...