diff --git a/README.md b/README.md index 68a4d59f..2a7fbf4a 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,41 @@ PR is welcome! ``` +##Independent use + +If you are going to use filemanager independently,meaning set the value of an input to selected photo/file url,follow this structure: + +1. create a popup window or modal(whatever you like): + +```html + + +``` + +```javascript + $('#feature-img-container').on('click', function(e) + { + + window.open(this.href, 'Filemanager', 'width=900,height=600'); + + return false; + }); +``` + +2. define a function named `SetUrl`: + +```javascript + function SetUrl(url){ + + //set the value of the desired input to image url,often this is a hidden input + $('#thumbnail').val(url); + + //set or change the feature image src,recall wordpress feature image + $('#feature-img-container').find('img').attr('src',url); + } +``` + + ## Config In `config/lfm.php` : diff --git a/composer.json b/composer.json index 4fabaace..aeada020 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,8 @@ "tinymce", "upload", "file", - "manager" + "manager", + "image" ], "authors": [ { diff --git a/src/controllers/LfmController.php b/src/controllers/LfmController.php index 4ad72992..23c08159 100644 --- a/src/controllers/LfmController.php +++ b/src/controllers/LfmController.php @@ -91,13 +91,18 @@ private function formatLocation($location, $type = null, $get_thumb = false) $working_dir = substr($working_dir, 1); } + $location .= $working_dir; if ($type === 'directory' || $type === 'thumb') { $location .= DIRECTORY_SEPARATOR; } - if ($type === 'thumb') { + //if user is inside thumbs folder there is no need + // to add thumbs substring to the end of $location + $in_thumb_folder = preg_match('/'.Config::get('lfm.thumb_folder_name').'$/i',$working_dir); + + if ($type === 'thumb' && !$in_thumb_folder) { $location .= Config::get('lfm.thumb_folder_name') . DIRECTORY_SEPARATOR; } @@ -126,6 +131,8 @@ public function getUrl($type = null) $url = $this->formatLocation($url, $type); + $url = str_replace('\\','/',$url); + return $url; } @@ -155,7 +162,7 @@ public function getFileName($file) $working_dir_start = $lfm_dir_start + strlen($this->file_location); $lfm_file_path = substr($file, $working_dir_start); - $arr_dir = explode(DIRECTORY_SEPARATOR, $lfm_file_path); + $arr_dir = explode('/', $lfm_file_path); $arr_filename['short'] = end($arr_dir); $arr_filename['long'] = DIRECTORY_SEPARATOR . $lfm_file_path; diff --git a/src/views/index.blade.php b/src/views/index.blade.php index 27e2386d..99f76e07 100644 --- a/src/views/index.blade.php +++ b/src/views/index.blade.php @@ -150,7 +150,7 @@