diff --git a/inc/common.php b/inc/common.php
index 28b527633d1845ccab4547caac643a241758ed0d..d4265f78cd24a1a32a6bcd3fe26cfd5ebe09a001 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -86,32 +86,20 @@ function formSecurityToken($print = true) {
 }
 
 /**
- * Return info about the current document as associative
- * array.
+ * Determine basic information for a request of $id
  *
- * @author Andreas Gohr <andi@splitbrain.org>
+ * @param unknown_type $id
+ * @param unknown_type $httpClient
  */
-function pageinfo() {
-    global $ID;
-    global $REV;
-    global $RANGE;
+function basicinfo($id, $htmlClient=true){
     global $USERINFO;
-    global $lang;
-
-    // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml
-    // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary
-    $info['id']  = $ID;
-    $info['rev'] = $REV;
 
     // set info about manager/admin status.
     $info['isadmin']   = false;
     $info['ismanager'] = false;
     if(isset($_SERVER['REMOTE_USER'])) {
-        $sub = new Subscription();
-
         $info['userinfo']   = $USERINFO;
-        $info['perm']       = auth_quickaclcheck($ID);
-        $info['subscribed'] = $sub->user_subscription();
+        $info['perm']       = auth_quickaclcheck($id);
         $info['client']     = $_SERVER['REMOTE_USER'];
 
         if($info['perm'] == AUTH_ADMIN) {
@@ -127,12 +115,40 @@ function pageinfo() {
         }
 
     } else {
-        $info['perm']       = auth_aclcheck($ID, '', null);
+        $info['perm']       = auth_aclcheck($id, '', null);
         $info['subscribed'] = false;
         $info['client']     = clientIP(true);
     }
 
-    $info['namespace'] = getNS($ID);
+    $info['namespace'] = getNS($id);
+
+    // mobile detection
+    if ($htmlClient) {
+        $info['ismobile'] = clientismobile();
+    }
+
+    return $info;
+ }
+
+/**
+ * Return info about the current document as associative
+ * array.
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function pageinfo() {
+    global $ID;
+    global $REV;
+    global $RANGE;
+    global $lang;
+
+    $info = basicinfo($ID);
+
+    // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml
+    // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary
+    $info['id']  = $ID;
+    $info['rev'] = $REV;
+
     $info['locked']    = checklock($ID);
     $info['filepath']  = fullpath(wikiFN($ID));
     $info['exists']    = @file_exists($info['filepath']);
@@ -210,8 +226,18 @@ function pageinfo() {
         }
     }
 
-    // mobile detection
-    $info['ismobile'] = clientismobile();
+    return $info;
+}
+
+/**
+ * Return information about the current media item as an associative array.
+ */
+function mediainfo(){
+    global $NS;
+    global $IMG;
+
+    $info = basicinfo("$NS:*");
+    $info['image'] = $IMG;
 
     return $info;
 }
diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php
index 04dd178cc82a81ac2c242bf102d53d34f0896424..7e05435405ff9118385c97114c852254fdf22b0e 100644
--- a/lib/exe/mediamanager.php
+++ b/lib/exe/mediamanager.php
@@ -7,15 +7,11 @@
 
     require_once(DOKU_INC.'inc/init.php');
 
-    trigger_event('MEDIAMANAGER_STARTED',$tmp=array());
-    session_write_close();  //close session
-
     global $INPUT;
     // handle passed message
     if($INPUT->str('msg1')) msg(hsc($INPUT->str('msg1')),1);
     if($INPUT->str('err')) msg(hsc($INPUT->str('err')),-1);
 
-
     // get namespace to display (either direct or from deletion order)
     if($INPUT->str('delete')){
         $DEL = cleanID($INPUT->str('delete'));
@@ -29,10 +25,14 @@
         $NS  = getNS($IMG);
     }else{
         $NS = cleanID($INPUT->str('ns'));
+        $IMG = null;
     }
 
-    // check auth
-    $AUTH = auth_quickaclcheck("$NS:*");
+    $INFO = mediainfo();
+    $AUTH = $INFO['perm'];    // shortcut for historical reasons
+
+    trigger_event('MEDIAMANAGER_STARTED',$tmp=array());
+    session_write_close();  //close session
 
     // do not display the manager if user does not have read access
     if($AUTH < AUTH_READ && !$fullscreen) {