We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Problem
Drew McLellan

Drew McLellan 2638 points
Perch Support

We use FileInfo to detect the type of file - that will have its own methods of detecting SVG.

What does this output on your server?

<?php

echo is_svg('/full/path/to/your/file.svg');

function is_svg($image_path) {

    if (function_exists('finfo_open')) {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        if ($finfo) {
            $mime_type = finfo_file($finfo, $image_path);  
            finfo_close($finfo);

            if (strpos($mime_type, 'svg')) {
                return $mime_type;
            }
        } 
    }else{
        // This is deprecated, but throw me a bone
        if (function_exists('mime_content_type')) {
            $mime_type = mime_content_type($image_path);
            if ($mime_type && strpos($mime_type, 'svg')) {
                return $mime_type;
            }
        }
    }

    // This is not an exact science, people.
    if (isset($mime_type)) {
        if ($mime_type=='text/plain' && PerchUtil::file_extension($image_path)=='svg') {
            return 'image/svg+xml';
        }
        if ($mime_type=='text/plain' && PerchUtil::file_extension($image_path)=='svgz') {
            return 'image/svg+xml';
        }
    }

    return 'no clue';
}


?>

it outputs no clue. But I also tested it with a valid SVG file (in terms of the assets) and that also outputs no clue.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is this on the production server?

Yes on both production and local.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok. I don't have a solution. It's something I'll need to see if we can accept for in the future.