Skip to content

Instantly share code, notes, and snippets.

@tauno
Created December 5, 2012 20:36
Show Gist options
  • Save tauno/4219257 to your computer and use it in GitHub Desktop.
Save tauno/4219257 to your computer and use it in GitHub Desktop.
imce_image_info replacement for pantheon. Replace function in inc/imce.page.inc. Based on http://helpdesk.getpantheon.com/customer/portal/articles/805234-working-with-imce-on-pantheon and http://drupal.org/node/1822320
<?php
/**
* Check if the file is an image and return info.
*/
function imce_image_info($file) {
if (function_exists('apc_fetch')) {
$cache = apc_fetch($file);
if ($cache) {
return $cache;
}
}
$mimes = array('image/jpeg' => IMAGETYPE_JPEG, 'image/gif' => IMAGETYPE_GIF, 'image/png' => IMAGETYPE_PNG);
if (is_file($file) && ($dot = strrpos($file, '.')) && in_array(strtolower(substr($file, $dot+1)), array('jpg', 'jpeg', 'gif', 'png'))
&& ($info = @image_get_info($file)) && isset($mimes[$info['mime_type']]) ) {
$result = array(
'width' => $info['width'],
'height' => $info['height'],
'type' => $mimes[$info['mime_type']],
'mime' => $info['mime_type']
);
apc_add($file, $result);
return $result;
}
return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment