diff --git a/inc/html.php b/inc/html.php
index 2b4e2835e05b0a03d7446d2d7dee26c46135a9d5..c58fd64ad60a33f2ae9dc72b92cb23df4752bcee 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -695,20 +695,28 @@ function html_recent($first=0, $show_changes='both'){
         $form->addElement(form_makeCloseTag('span'));
 
         if ($recent['media']) {
-            $href = media_managerURL(array('tab_details' => 'history',
-                'mediado' => 'diff', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
+            $diff = (count(getRevisions($recent['id'], 0, 1, 8192, true)) && @file_exists(mediaFN($recent['id'])));
+            if ($diff) {
+                $href = media_managerURL(array('tab_details' => 'history',
+                    'mediado' => 'diff', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
+            }
         } else {
             $href = wl($recent['id'],"do=diff", false, '&');
         }
-        $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => $href)));
-        $form->addElement(form_makeTag('img', array(
-                        'src'   => DOKU_BASE.'lib/images/diff.png',
-                        'width' => 15,
-                        'height'=> 11,
-                        'title' => $lang['diff'],
-                        'alt'   => $lang['diff']
-                        )));
-        $form->addElement(form_makeCloseTag('a'));
+
+        if ($recent['media'] && !$diff) {
+            $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
+        } else {
+            $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => $href)));
+            $form->addElement(form_makeTag('img', array(
+                            'src'   => DOKU_BASE.'lib/images/diff.png',
+                            'width' => 15,
+                            'height'=> 11,
+                            'title' => $lang['diff'],
+                            'alt'   => $lang['diff']
+                            )));
+            $form->addElement(form_makeCloseTag('a'));
+        }
 
         if ($recent['media']) {
             $href = media_managerURL(array('tab_details' => 'history',
diff --git a/inc/media.php b/inc/media.php
index 8c23dc115cd286927c83bc0647ce5e87d1c8185d..c009785fd5fd145693c17ecc7df83a00a20d5ad3 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -313,7 +313,7 @@ function media_save($file, $id, $ow, $auth, $move) {
         }
     }
 
-    global $lang;
+    global $lang, $conf;
 
     // get filename
     $id   = cleanID($id,false,true);
@@ -603,7 +603,7 @@ function media_tabs_details($image, $selected=false){
     media_tab(media_managerURL(array('tab_details' => 'view')), 'view', $lang['media_viewtab'], $selected);
 
     list($ext, $mime) = mimetype($image);
-    if ($mime == 'image/jpeg') {
+    if ($mime == 'image/jpeg' && @file_exists(mediaFN($image))) {
         media_tab(media_managerURL(array('tab_details' => 'edit')), 'edit', $lang['media_edittab'], $selected);
     }
     if ($conf['mediarevisions']) {
@@ -867,12 +867,15 @@ function media_preview_buttons($image, $auth, $rev=false) {
     }
     $link = ml($image,$more,true,'&');
 
-    // view original file button
-    $form = new Doku_Form(array('action'=>$link, 'target'=>'_blank'));
-    $form->addElement(form_makeButton('submit','',$lang['mediaview']));
-    $form->printForm();
+    if (@file_exists(mediaFN($image, $rev))) {
+
+        // view original file button
+        $form = new Doku_Form(array('action'=>$link, 'target'=>'_blank'));
+        $form->addElement(form_makeButton('submit','',$lang['mediaview']));
+        $form->printForm();
+    }
 
-    if($auth >= AUTH_DELETE && !$rev){
+    if($auth >= AUTH_DELETE && !$rev && @file_exists(mediaFN($image))){
 
         // delete button
         $form = new Doku_Form(array('id' => 'mediamanager__btn_delete',
@@ -892,7 +895,7 @@ function media_preview_buttons($image, $auth, $rev=false) {
         $form->printForm();
     }
 
-    if($auth >= AUTH_DELETE && $rev && $conf['mediarevisions']){
+    if($auth >= AUTH_DELETE && $rev && $conf['mediarevisions'] && @file_exists(mediaFN($image, $rev))){
 
         // restore button
         $form = new Doku_Form(array('id' => 'mediamanager__btn_restore',
@@ -916,7 +919,7 @@ function media_preview_buttons($image, $auth, $rev=false) {
  * @return array
  */
 function media_image_preview_size($image, $rev, $meta, $size = 500) {
-    if (!preg_match("/\.(jpe?g|gif|png)$/", $image)) return false;
+    if (!preg_match("/\.(jpe?g|gif|png)$/", $image) || !file_exists(mediaFN($image, $rev))) return false;
 
     $info = getimagesize(mediaFN($image, $rev));
     $w = (int) $info[0];
@@ -1206,7 +1209,8 @@ function media_image_diff($image, $l_rev, $r_rev, $meta, $type) {
 function media_restore($image, $rev, $auth){
     global $conf;
     if ($auth < AUTH_DELETE || !$conf['mediarevisions']) return false;
-    if (!$image || !file_exists(mediaFN($image))) return false;
+    $removed = (!file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes')));
+    if (!$image || (!file_exists(mediaFN($image)) && !$removed)) return false;
     if (!$rev || !file_exists(mediaFN($image, $rev))) return false;
     list($iext,$imime,$dl) = mimetype($image);
     $res = media_upload_finish(mediaFN($image, $rev),
@@ -1526,16 +1530,17 @@ function media_managerURL($params=false, $amp='&amp;', $abs=false) {
  * @author Kate Arzamastseva <pshns@ukr.net>
  */
 function media_uploadform($ns, $auth, $fullscreen = false){
-    global $lang;
+    global $lang, $conf;
 
     if($auth < AUTH_UPLOAD) {
         echo '<div class="nothing">'.$lang['media_perm_upload'].'</div>'.NL;
         return;
     }
+    $auth_ow = (($conf['mediarevisions']) ? AUTH_UPLOAD : AUTH_DELETE);
 
     $update = false;
     $id = '';
-    if ($auth >= AUTH_DELETE && $fullscreen && $_REQUEST['mediado'] == 'update') {
+    if ($auth >= $auth_ow && $fullscreen && $_REQUEST['mediado'] == 'update') {
         $update = true;
         $id = cleanID($_REQUEST['image']);
     }
@@ -1562,7 +1567,7 @@ function media_uploadform($ns, $auth, $fullscreen = false){
     $form->addElement(form_makeButton('submit', '', $lang['btn_upload']));
     $form->addElement(form_makeCloseTag('p'));
 
-    if($auth >= AUTH_DELETE){
+    if($auth >= $auth_ow){
         $form->addElement(form_makeOpenTag('p'));
         $attrs = array();
         if ($update) $attrs['checked'] = 'checked';
diff --git a/inc/template.php b/inc/template.php
index e6673c3f3b8f1edfd9ab5a7de316d4cfb8d96248..04e3e79ccd4b3501ee4761dd3796db68cfcc1a7c 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1174,7 +1174,8 @@ function tpl_fileList(){
 function tpl_fileDetails($image, $rev){
     global $AUTH, $NS, $conf;
 
-    if (!$image || !file_exists(mediaFN($image))) return '';
+    $removed = (!file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes')) && $conf['mediarevisions']);
+    if (!$image || (!file_exists(mediaFN($image)) && !$removed)) return '';
     if ($rev && !file_exists(mediaFN($image, $rev))) $rev = false;
     if (isset($NS) && getNS($image) != $NS) return '';
     $do = $_REQUEST['mediado'];
@@ -1201,7 +1202,7 @@ function tpl_fileDetails($image, $rev){
         media_tab_view($image, $NS, $AUTH, $rev);
         echo '</div>';
 
-    } elseif ($opened_tab == 'edit') {
+    } elseif ($opened_tab == 'edit' && !$removed) {
         echo '<div id="mediamanager__details">';
         media_tab_edit($image, $NS, $AUTH);
         echo '</div>';
diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php
index 300fb8acbec951d2a413e668d8402a09d39ab261..20fc99de41c5f2b7aba18addfb4f37c52a9ad1c8 100644
--- a/lib/exe/ajax.php
+++ b/lib/exe/ajax.php
@@ -222,7 +222,7 @@ function ajax_medialist(){
  * @author Kate Arzamastseva <pshns@ukr.net>
  */
 function ajax_mediadetails(){
-    global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen;
+    global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen, $conf;
     $fullscreen = true;
     require_once(DOKU_INC.'lib/exe/mediamanager.php');