Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Commit

Permalink
fix(uploads): correctly display (new) uploaded images in all image fi…
Browse files Browse the repository at this point in the history
…letypes supported by ckeditor
  • Loading branch information
iionly committed Mar 12, 2017
1 parent 21dd9b1 commit 7a9ed53
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
2 changes: 2 additions & 0 deletions actions/ckeditor/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand Down
4 changes: 0 additions & 4 deletions start.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 1 addition & 10 deletions views/default/object/ckeditor_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7a9ed53

Please sign in to comment.