From 7a9ed534a588fcf386c52093e1bb06aebcefb825 Mon Sep 17 00:00:00 2001 From: iionly Date: Sun, 12 Mar 2017 10:51:25 +0100 Subject: [PATCH] fix(uploads): correctly display (new) uploaded images in all image filetypes supported by ckeditor --- actions/ckeditor/upload.php | 2 ++ start.php | 4 ---- views/default/object/ckeditor_file.php | 11 +---------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/actions/ckeditor/upload.php b/actions/ckeditor/upload.php index bb366cf..e2a2a49 100644 --- a/actions/ckeditor/upload.php +++ b/actions/ckeditor/upload.php @@ -70,6 +70,8 @@ $file->transfer($file->owner_guid, "ckeditor/{$hash}.{$ext}"); +$file->hash = $hash; +$file->ext = $ext; $file->save(); $url = elgg_normalize_url("ckeditor/image/{$user->guid}/{$hash}/{$ext}"); diff --git a/start.php b/start.php index 904829d..abcf7c8 100644 --- a/start.php +++ b/start.php @@ -140,10 +140,6 @@ function ckeditor_addons_page_handler($segments) { exit; } - if (!in_array($ext, array('jpg', 'gif'))) { - $ext = 'jpg'; - } - if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"$hash\"") { header("HTTP/1.1 304 Not Modified"); exit; diff --git a/views/default/object/ckeditor_file.php b/views/default/object/ckeditor_file.php index 6ff4818..8f2b4ad 100644 --- a/views/default/object/ckeditor_file.php +++ b/views/default/object/ckeditor_file.php @@ -5,17 +5,8 @@ $entity = elgg_extract('entity', $vars); /* @var $entity CKFile */ -$hash = md5(file_get_contents($entity->getFilenameOnFilestore())); -switch ($entity->getMimeType()) { - case 'image/gif' : - $ext = 'gif'; - break; - default : - $ext = 'jpg'; -} - $img = elgg_format_element('img', array( - 'src' => elgg_normalize_url("ckeditor/image/$entity->owner_guid/$hash/$ext"), + 'src' => elgg_normalize_url("ckeditor/image/$entity->owner_guid/$entity->hash/$entity->ext"), 'class' => 'ckeditor-browser-image', 'data-callback' => elgg_extract('ckeditor_callback', $vars), 'width' => 100,