Image Type SVG

16 posts by 5 authors in: Forums > CMS Builder
Last Post: February 5, 2021   (RSS)

By Toledoh - October 27, 2020

Hi All.

Re: https://www.interactivetools.com/forum/forum-posts.php?postNum=2239394#post2239394

Are SVG's displaying in admin correctly now?  This old post seems to refer to code that has been changed now in  \cmsb\lib\upload_functions.php, but I'm not seeing svg's in the admin, I just get the "download" link.

Cheers,

Tim (toledoh.com.au)

By hans - October 30, 2020

Hello.

I believe the problem is in the configuration of the section's allowed file extensions. At one point, svg uploads were allowed, then the settings were changed that removed svg from the list of available file extensions.

-----

To remedy this problem, go to the section editor in your admin panel > fields table (Has no label, but it's the last table on the list)

Look for a field named Uploads, then edit it by clinking modify. Then go to a section named "Input Validation" and search a column named "File extensions allowed". Check to see that svg is in the list of file extensions that are allowed to be uploaded.

Hans Marcon
PHP Programmer (In Training)
interactivetools.com
Attachments:

step1.png 34K

step2.png 26K

By Toledoh - October 30, 2020

Sorry Hans, I wasn't clear in what I was trying to do.

I can upload SVG's, but when displaying the "uploads" column, I get a "download" rather than an image preview.  That previous post was to (I think) bypass the thumbnail creation as SVG doesn't require it?

Cheers,

Tim (toledoh.com.au)

By hans - November 9, 2020

Hello Toledoh.

Let's check all the possible reasons why the SVG isn't displaying a preview.

In CMS Builder v3.53 (Build 2265), the preview of SVG files are displayed. What version of CMS builder do you have?

Also, can you show a screenshot of an upload list with an SVG file uploaded? In normal circumstances, it would look like the image file below.

Hans Marcon
PHP Programmer (In Training)
interactivetools.com
Attachments:

uploadpreview.png 41K

By Toledoh - November 9, 2020

Hi Hans.

Thanks for looking into this for me.

I'm using v3.55 (Build 2288) which has some trial Media Library components, but I'm confident that this wasn't working prior to this update.

I've attached a sample SVG and a few screenshots of the relative areas.

Cheers,

Tim (toledoh.com.au)

By hans - November 13, 2020

Hello... I would like you to go to your CMSB directory and find lib/upload_functions.php, then go to the showUploadPreview() method.

Find the line containing 

if ($isImage && $bestSrc) { $html .= "<img src='$bestSrc' border='0' width='$bestWidth' height='$bestHeight' alt='$title' title='$title'>"; }

Replace it with

if ($isImage) { $html .= "<img src='$bestSrc' border='0' width='$bestWidth' height='$bestHeight' alt='$title' title='$title'>"; }

Assuming that the image is included in the list of image file extensions, an image preview should show up instead of the download link.

Hans Marcon
PHP Programmer (In Training)
interactivetools.com

By Toledoh - November 13, 2020

Sorry Hans - still not right.

For the svg, we need the $bestSrc to be the original image url?

Cheers,

Tim (toledoh.com.au)

By hans - November 17, 2020 - edited: November 17, 2020

I removed that clause, thinking it was one less condition that had to be fulfilled in order to recognize svg's as an image in that case.

Would you be interested in a call to get this issue resolved? Screen sharing will help tremendously in finding out the root cause of the problem.

Hans Marcon
PHP Programmer (In Training)
interactivetools.com

By Steve99 - November 18, 2020 - edited: November 18, 2020

Hi Guys,

I was able to replicate this issue as well. Troubleshooting yielded some potentially helpful info.

Troubleshooting Steps:

- Upload SVG to record and save (download link shows)

- Edit Section > Modify Upload Field > Input Validation - Click "recreate" action on Create Thumbnail line

- Go back to view record and the SVG preview displays

--

Update:

In appears since the SVG upload doesn't save a width or height it fails the current process conditions for displaying as an image in func showUploadPreview

By Toledoh - November 25, 2020

Hi Hans.

Sorry - I thought I had replied to this - yes I would be interested in a call if you like?  Zoom or Skype?

Cheers,

Tim (toledoh.com.au)