This is a migrated thread and some comments may be shown as answers.

Bug in ImageBrowser

1 Answer 12 Views
General Disccussions
This is a migrated thread and some comments may be shown as answers.
Rinck
Top achievements
Rank 1
Rinck asked on 05 Apr 2013, 08:28 AM
Hi,
I'm experimenting with the IimageBrowser (php) and ran into an issue.

When creating a new instance of the ImageBrowser class, I received an error:
Parse error: syntax error, unexpected '[' in /var/www/test/Kendo/ImageBrowser.php on line 43
That line contains the following function (the second line is the culprit here):
function getImageType($filename) {
    $type = getimagesize($filename)[2];
 
    if ($type == IMAGETYPE_JPEG) {
        $type = 'jpeg';
    } elseif ($type == IMAGETYPE_GIF) {
        $type = 'gif';
    } elseif ($type == IMAGETYPE_PNG) {
        $type = 'png';
    }
 
    return $type;
}
Trying to access an array index directly on the functioncall does not seem to do well with my PHP version:
PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli) (built: Mar 11 2013 14:31:48)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
An easy fix is to change the function to the following:
function getImageType($filename) {
    $type = getimagesize($filename);
 
    if ($type[2] == IMAGETYPE_JPEG) {
        $type = 'jpeg';
    } elseif ($type[2] == IMAGETYPE_GIF) {
        $type = 'gif';
    } elseif ($type[2] == IMAGETYPE_PNG) {
        $type = 'png';
    }
 
    return $type;
}
Hope that helps someone... :)

1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 08 Apr 2013, 02:44 PM
Hello Rinck,

Thank you for the feedback! We have fixed the problem, so the next internal build will feature this. I updated your Telerik points as a small token of gratitude.

All the best,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Disccussions
Asked by
Rinck
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or