diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php
index b0433898cda88aa8cf26309f773f4618e2aaefba..1b3ad48f561046574d6f3c7ffadcf5580196a8c5 100644
--- a/apps/gallery/ajax/galleryOp.php
+++ b/apps/gallery/ajax/galleryOp.php
@@ -127,6 +127,9 @@ function handleGetGallery($path) {
 function handleShare($path, $share, $recursive) {
   $recursive = $recursive == 'true' ? 1 : 0;
   $owner = OC_User::getUser();
+  $root = OC_Preferences::getValue(OC_User::getUser(),'gallery', 'root', '/');
+  $path = utf8_decode(rtrim($root.$path,'/'));
+  if($path == '') $path = '/';
   $r = OC_Gallery_Album::find($owner, null, $path);
   if ($row = $r->fetchRow()) {
     $albumId = $row['album_id'];