core icon indicating copy to clipboard operation
core copied to clipboard

Problems with SVG images as Image Field

Open scrossley opened this issue 10 years ago • 19 comments

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]

scrossley avatar Feb 01 '16 13:02 scrossley

We need to insure that we support SVG images and that they render correctly

wezell avatar Apr 14 '16 14:04 wezell

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)

levosgien avatar Apr 18 '16 20:04 levosgien

@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;
                }

            }

wezell avatar Apr 19 '16 15:04 wezell

oops

wezell avatar Apr 19 '16 15:04 wezell

@wezell OK, I was checking the ThumbnailImage Servlet just right know, I am going to check the BinaryExporterServlet instead then

freddyucv avatar Apr 19 '16 15:04 freddyucv

@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 avatar Apr 19 '16 15:04 wezell

@wezell ok

freddyucv avatar Apr 19 '16 17:04 freddyucv

@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.

levosgien avatar Apr 20 '16 15:04 levosgien

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 avatar Apr 21 '16 11:04 scrossley

@scrossley we are able to reproduce, thank you.

levosgien avatar Apr 21 '16 14:04 levosgien

PR: https://github.com/dotCMS/core/pull/8947

freddyucv avatar Apr 25 '16 20:04 freddyucv

master-3.5 PR: https://github.com/dotCMS/core/pull/8947 master-3.6 PR: https://github.com/dotCMS/core/pull/9016

jgambarios avatar May 05 '16 20:05 jgambarios

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...

r2

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

bryanboza avatar May 05 '16 22:05 bryanboza

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

bryanboza avatar May 05 '16 22:05 bryanboza

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.

jgambarios avatar May 06 '16 22:05 jgambarios

Question, does the SVG file re-index properly - you will need an EE license to test.

wezell avatar May 20 '16 15:05 wezell

Fixed, tested on master-3.5 // MySQL // FF

bryanboza avatar May 26 '16 21:05 bryanboza

@bryanboza we tested the re-index? https://github.com/dotCMS/core/issues/8551#issuecomment-220643878

jgambarios avatar May 27 '16 13:05 jgambarios

Yes, I tested with license and without it, and in both cases woks as expected... No errors...

bryanboza avatar May 27 '16 17:05 bryanboza