Skip to content

Instantly share code, notes, and snippets.

@tauno
Created December 7, 2012 20:08
Show Gist options
  • Save tauno/4236123 to your computer and use it in GitHub Desktop.
Save tauno/4236123 to your computer and use it in GitHub Desktop.
Patch for Drupal IMCE 1.6 module to make it work better on Pantheon
diff --git a/inc/imce.page.inc b/inc/imce.page.inc
index 5c60d53..1598f8b 100644
--- a/inc/imce.page.inc
+++ b/inc/imce.page.inc
@@ -682,9 +682,19 @@ function imce_validate_quotas($file, &$imce, $add = 0) {
*/
if (variable_get('imce_image_get_info', 0)) {
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']]) ) {
- return array('width' => $info['width'], 'height' => $info['height'], 'type' => $mimes[$info['mime_type']], 'mime' => $info['mime_type']);
+ $result = array('width' => $info['width'], 'height' => $info['height'], 'type' => $mimes[$info['mime_type']], 'mime' => $info['mime_type']);
+ if (function_exists('apc_add')) {
+ apc_add($file, $result);
+ }
+ return $result;
}
return FALSE;
}
@@ -980,7 +990,7 @@ function imce_scan_directory($dirname, $imce) {
while (($file = readdir($handle)) !== FALSE) {
// Do not include dot files and folders
- if (substr($file, 0, 1) === '.') {
+ if ((substr($file, 0, 1) === '.') || $file == 'lost+found') {
continue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment