Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,41 @@ PR is welcome!
</script>
```

##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
<a href="/laravel-filemanager" id="feature-img-container"><img src="no_photo.jpg"></a>
<input name="thumbnail" type="hidden" id="thumbnail">
```

```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` :
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"tinymce",
"upload",
"file",
"manager"
"manager",
"image"
],
"authors": [
{
Expand Down
11 changes: 9 additions & 2 deletions src/controllers/LfmController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -126,6 +131,8 @@ public function getUrl($type = null)

$url = $this->formatLocation($url, $type);

$url = str_replace('\\','/',$url);

return $url;
}

Expand Down Expand Up @@ -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;

Expand Down
8 changes: 5 additions & 3 deletions src/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<script src="/vendor/laravel-filemanager/js/cropper.min.js"></script>
<script src="/vendor/laravel-filemanager/js/jquery.form.min.js"></script>
<script>
var ds = "{{ DIRECTORY_SEPARATOR }}";
var ds = "{{ addslashes(DIRECTORY_SEPARATOR) }}";
var home_dir = ds + "{{ (Config::get('lfm.allow_multi_user')) ? Auth::user()->user_field : '' }}";
var shared_folder = ds + "{{ Config::get('lfm.shared_folder_name') }}";
var image_url = "{{ Config::get('lfm.images_url') }}";
Expand Down Expand Up @@ -445,6 +445,7 @@ function getUrlParam(paramName) {

var field_name = getUrlParam('field_name');
var url = item_url + file;
url = url.replace(/\\/g,"/");

if (window.opener || window.tinyMCEPopup || field_name || getUrlParam('CKEditorCleanUpFuncNum') || getUrlParam('CKEditor')) {
if (window.tinyMCEPopup) {
Expand Down Expand Up @@ -486,9 +487,8 @@ function getUrlParam(paramName) {
parent.CKEDITOR.tools.callFunction(getUrlParam('CKEditorCleanUpFuncNum'));
}
} else {

// use FCKEditor 2.0 integration method
if (data['Properties']['Width'] != '') {
if (typeof data != 'undefined' && data['Properties']['Width'] != '') {
var p = url;
var w = data['Properties']['Width'];
var h = data['Properties']['Height'];
Expand All @@ -507,6 +507,7 @@ function getUrlParam(paramName) {

window.close();
}
//end useFile

function notImp() {
bootbox.alert('Not yet implemented!');;
Expand All @@ -533,6 +534,7 @@ function makeRandom() {
}
return text;
}

</script>
</body>
</html>