pendalf89 / yii2-filemanager Goto Github PK
View Code? Open in Web Editor NEWYii2 file manager
License: MIT License
Yii2 file manager
License: MIT License
Hello. Hope you don't mind with some my issues.
I have updated my region language folder but I don't know how to setting this extension run with my region language. I'm looking forward from you soon. Thanks so much. (y)
Доброй ночи!
В файле Mediafilebehavior в строках 41 и 55 используется запрос медиа по url. Однако не всегда эти значения передаются по url. Иногда используется ID. Можно ли сделать возможность выбора id/url?
I don't want that every image that I upload creates all of those same thumbnail variants that are defined in configuration, I would like to see two-level thumbnail configuration options. For example, when user uploads his new avatar, I want it to create 3 thumbnails 50x50, 100x100 and 200x200, but when user uploads new article image, I want it to create 2 thumbnails, 150x50 and 300x100 - I don't want three more thumbnails for article images that will not be ever used.
To achieve that, configuration could be grouped:
'modules' => [
'filemanager' => [
'class' => 'pendalf89\filemanager\Module',
// Upload routes
'routes' => [
// Base absolute path to web directory
'baseUrl' => '',
// Base web directory url
'basePath' => '@frontend/web',
// Path for uploaded files in web directory
'uploadPath' => 'uploads',
],
'default-thumbs' => 'default',
// Thumbnails info
'thumbs' => [
'default' => [
'small' => [
'name' => 'Мелкий',
'size' => [100, 100],
],
'medium' => [
'name' => 'Средний',
'size' => [300, 200],
],
'large' => [
'name' => 'Большой',
'size' => [500, 400],
],
],
'user-avatar' => [
'small' => [
'name' => 'Small',
'size' => [50, 50],
],
'medium' => [
'name' => 'Medium',
'size' => [100, 100],
],
'large' => [
'name' => 'Large',
'size' => [200, 200]
]
],
'article-image' => [
'intro' => [
'name' => 'Intro image',
'size' => [150, 50],
],
'full' => [
'name' => 'Full image',
'size' => [300, 100]
]
]
]
]
]
To provide backwards compatibility with current version, checking of thumbs
could be done to see if second level of first array element contains size
key, if so, thumbs
array is parsed in "no-groups" format, otherwise, it is parsed in "groups" format.
Thumbnail group should be provided as GET attribute during file manager module call through either URL or widget configuration.
In addition, for more flexibility and backwards compatibility for widget configurations without specific thumbnail group provided, default-thumbs
attribute provides default thumbs group.
When used within the repeatable fields the input/browse button is displayed and I can see the modal/iframe in my source.
On browse button click it just goes to home/base url.
I have the below code within my form:
<?php echo $form->field($model, 'publisher[{{row-count-placeholder}}][logo]')->widget(FileInput::className(), [
'id' => uniqid(),
'buttonTag' => 'button',
'buttonName' => 'Browse',
'buttonOptions' => ['class' => 'btn btn-default'],
'options' => ['class' => 'form-control'],
// Widget template
'template' => '<div class="input-group">{input}<span class="input-group-btn">{button}</span></div>',
// Optional, if set, only this image can be selected by user
'thumb' => 'original',
// Optional, if set, in container will be inserted selected image
'imageContainer' => '.img',
// Default to FileInput::DATA_URL. This data will be inserted in input field
'pasteData' => FileInput::DATA_URL,
// JavaScript function, which will be called before insert file data to input.
// Argument data contains file data.
// data example: [alt: "Ведьма с кошкой", description: "123", url: "/uploads/2014/12/vedma-100x100.jpeg", id: "45"]
'callbackBeforeInsert' => 'function(e, data) {
console.log( data );
}',
]); ?>
Which outputs the follow html
<div class="form-group field-reviews-publisher-1-logo">
<label class="control-label" for="reviews-publisher-1-logo">Publisher</label>
<div class="input-group"><input type="text" id="reviews-publisher-1-logo" class="form-control" name="Reviews[publisher][1][logo]"><span class="input-group-btn"><button id="reviews-publisher-1-logo-btn" class="btn btn-default" role="filemanager-launch">Browse</button></span></div>
<div role="filemanager-modal" class="modal" tabindex="-1" data-frame-id="reviews-publisher-1-logo-frame" data-frame-src="/backend/index.php?r=filemanager%2Ffile%2Ffilemanager" data-btn-id="reviews-publisher-1-logo-btn" data-input-id="reviews-publisher-1-logo" data-image-container=".img" data-paste-data="url" data-thumb="original">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body"></div>
</div>
</div>
</div>
<div class="help-block"></div>
</div>
I'm using your extension to manager image of an object. But in default,I can upload all file type such as audio file MP3. But I only want to upload Image file as JPG, PNG , GIF...So can you help me to setting to upload only image file. Thanks a lot.
is it posible to implement such features like moxiemanager on this link! look at the following features
-The interface of the fie manager on clicking browse button
-Selection of multiple files
-Editing of images
-Multiple view options i.e List and thumbnails
-Ability to create folders
-Multiple upload options like from machine,google drive and Dropbox etc
-Search & sort functionalities
I am willing to support inclusion of this features let me know if anyone else is interested
Some months ago you accept to change the name from TinyMce to TinyMCE this broke my code and I think the code from others, now you change it again.
Please revert your last commit and keep the name of the file as TinyMCE.
When using the filemanager using TinyMCE the variables imageContainer and pasteData are not assigned to the modal view causing an Undefined variable.
See pendalf89\yii2-filemanager\widgets\TinyMce.php line 82
Hello !
Just uploaded .ttf font but it has not appeared in the gallery.
Is it possible to upload fonts, pdfs, other files ?
I've noticed URL saved ignores the fact that the extension/module is not always on root of server.
My project is Subfolder of main projects folder and Instead of saving images URL in database url
field as /projects/myproject/web/uploads/2015/06/wwwgfaorg2.jpeg
it just puts /uploads/2015/06/wwwgfaorg2.jpeg
That would be fine if during Display it would concatenate with base URL aka @web
but it dioes not hence I get blank page with not found responses on firebug.
Is there a config that I miss? Here is my config part
'modules' => [
'filemanager' => [
'class' => 'pendalf89\filemanager\Module',
// Upload routes
'routes' => [
// Base absolute path to web directory
'baseUrl' => '',
// Base web directory url
'basePath' => '@webroot',
// Path for uploaded files in web directory
'uploadPath' => 'uploads',
],
],
],
Hello,
How can I use the owners after I am created or updated the post?
the owners table is empty and I can not use loadOneByOwner method.
Can you please explain me ?
Thanks
Hi,
I really like the filemanager and tinymce integration, but unfortunately I can't get it to work in my setup (advanced template).
I'd like to use the filemanager and tinymce from backend to upload images and show the images in the frontend. I did the following configuration in the backend app:
'routes' => [
'baseUrl' => '',
'basePath' => '@frontend/web',
'uploadPath' => 'uploads',
],
With this config the upload works fine to frontend but the images are not visible in the uploader. I can see in the JS-console, that the path is not correct:
uploads/2016/04/img0006-128x128.jpg
The right path would be:
frontend/web/uploads/2016/04/img0006-128x128.jpg
I know that "frontend/web" is not the right path in the live system, but I need this in my testing environment. Is it possible to configure the filemanager in a way, so that it can handle this path aswell?
I allready played around with the "baseUrl" but it seems that this has no influence to my issue.
So long
Sven
Currently, when Mediafile::createThumbs()
creates thumbnails, it does not provide "mode" of image resizing, that leads to cropping image by default using ImageInterface::THUMBNAIL_OUTBOUND
mode.
I would like to be able to provide within thumbnail configuration, which mode exactly to use.
Hi,
Is there any chance to call a function after new file is uploaded via the manager? I'd like to log every file upload. Thanks!
When using file manager without ownership feature, after tens or hundreds of images has been uploaded, it is getting hard to use file manager view. When it is required to search and find images, when visual look on thumbnail is not enough, search by some additional parameters, like creation date, title, description etc is required.
This could be achieved either by adding just couple search boxes on top of file manager or even better - by creating switchable "Detail view". This could be done with GridVew widget, that provides parameters and filtering/ordering options.
can you give a demo? thank you !
Hello, I create a pull request for you to upload my region language.Hope to you merge soon. Thank you.
In MediafileBehavior.php replace:
private function loadModel($url)
{
return Mediafile::findByUrl($url);
}
Tried to install from composer but package not found error has occured.
https://github.com/PendalF89/yii2-filemanager/blob/master/widgets/TinyMCE.php
Class name does not match the file name
class TinyMce extends InputWidget
i use fileinput
in Firebug i got this, please help.
TypeError: modal.modal is not a function
modal.modal("show");
example.com/web/filemanager/file/filemanager" not found
Hello. Thank you for this great module!
I started to learn yii2 a few week ago. I never using this framework (yii1) never before. Excuse me if I writing something stupid..
In my project this module has one problem. With routes...
I use Yii2 advanced. I included this filemanager in backend. I tried to configured common/config/main.php:
'modules' => [
'filemanager' => [
'class' => 'pendalf89\filemanager\Module',
// Upload routes
'routes' => [
// Base absolute path to web directory
'baseUrl' => '',
// Base web directory url
'basePath' => '@frontend/web/images/',
// Path for uploaded files in web directory
'uploadPath' => 'uploads',
],
// Thumbnails info
'thumbs' => [
'small' => [
'name' => 'Small',
'size' => [100, 100],
],
'medium' => [
'name' => 'Medium',
'size' => [300, 200],
],
'large' => [
'name' => 'Big',
'size' => [500, 400],
],
],
],
]
But images not showing. Image files - has writed to database, has uploaded to path which I configured - '/frontend/web/images/uploads/YYYY/MM'. And I have a field 'url' in database = '/uploads/2015/04/mestoraspolozhenie-xolodilnika.jpg' for example, but folder with my image is '/frontend/web/images/uploads/2015/04/mestoraspolozhenie-xolodilnika.jpg', so I added something to config in my backend/config/main.php:
'modules' => [
'filemanager' => [
'routes' => [
'content_image_path' => '/frontend/web/images',
],
],
],
and I included this in two methods of models/Mediafile.php:
method №1: getDefaultThumbUrl
public function getDefaultThumbUrl($baseUrl = '')
{
// ....... code ......
// standart code:
// return "$dirname/$filename-{$width}x{$height}.$extension";
// my code:
return Yii::$app->getModule('filemanager')->routes['content_image_path']."$dirname/$filename-{$width}x{$height}.$extension";
}
method №2: getImagesList
public function getImagesList(Module $module)
{
// ....... code ......
foreach ($thumbs as $alias => $url) {
$preset = $module->thumbs[$alias];
// standart code:
// $list[$url] = $preset['name'] . ' ' . $preset['size'][0] . ' × ' . $preset['size'][1];
// my code:
$list[$module->routes['content_image_path'].$url] = $preset['name'] . ' ' . $preset['size'][0] . ' × ' . $preset['size'][1];
}
$originalImageSize = $this->getOriginalImageSize($module->routes);
// standart code:
// $list[$this->url] = Module::t('main', 'Original') . ' ' . $originalImageSize;
// my code:
$list[$module->routes['content_image_path'].$this->url] = Module::t('main', 'Original') . ' ' . $originalImageSize;
return $list;
}
After this manipulations the problem is gone. I hope so....
Excuse me, friend, if something wrong. It's my first Issue))).
Apologies about opening another issue however I seem to have none of the styling that is seen in your screen shots (i really want to get this installed as it is awesome).
I have installed it and uploads are working although I need to configure the path properly, however there's no styling.
Any ideas?
How do i insert multiple files?
Hello,
thank you for this great extensions.
I have a problem with it when I use it with TinyMCE (web version):
Result: impossible to select an image.
I looked in the code a solution, but for now, I have found nothing.
How can I fix this?
Thank you in advance for your reply.
Arnaud
Hi your file manager looks awesome, I was just trying to install in via composer and get the following message:
- The requested package pendalf89/yii2-filemanager could not be found in any version, there may be a typo in the package name.
Any ideas?
I have the following route setup in my backend config:
'routes' => [
// Base absolute path to web directory
'baseUrl' => '',
// Base web directory url
'basePath' => '@frontend',
// Path for uploaded files in web directory
'uploadPath' => 'uploads',
],
The files are uploaded to the correct directory however once uploaded the following message is displayed:
{"files":[{"url":"/uploads/2015/12/test.jpg","thumbnailUrl":"/backend/uploads/2015/12/test-128x128.jpg","name":"test.jpg","type":"image/jpeg","size":9713,"deleteUrl":"/backend/filemanager/file/delete?id=2","deleteType":"POST"}]}
As you can see the thumbnail URL has backend at the beginning which isn't necessary.
I would like to see an option to disable file title and description for situations when similar fields are provided elsewhere, it is confusing users thus creating worse user experience.
eg Mediafile.php 187&220: save("$basePath/$thumbUrl", ['quality' => $preset['quality']]);
Thank You :-)
Consider the following two pieces of code:
public function getThumbs()
{
return unserialize($this->thumbs);
}
and
public function deleteThumbs(array $routes)
{
$basePath = Yii::getAlias($routes['basePath']);
foreach ($this->getThumbs() as $thumbUrl) {
unlink("$basePath/$thumbUrl");
}
unlink("$basePath/{$this->getDefaultThumbUrl()}");
}
I encountered a situation where the thumbnails weren't stored properly (max process time issue - not important :)), which caused deleteThumbs to break because the foreach()
was being run on a null value.
My suggestion: to make the code more bullet-proof, either modify getThumbs as follows:
public function getThumbs()
{
return unserialize($this->thumbs) ?: [];
}
or modify deleteThumbs() to cast the result of getThumbs as an array:
public function deleteThumbs(array $routes)
{
$basePath = Yii::getAlias($routes['basePath']);
foreach ((array)$this->getThumbs() as $thumbUrl) {
unlink("$basePath/$thumbUrl");
}
unlink("$basePath/{$this->getDefaultThumbUrl()}");
}
I can see most of Issues have no comment whatsoever. Wanted to know if it is abandoned or not.
Thanks
Currently, this file manager supports single level view of files, without any way to structure or organize files. I would like either some sort of similar multi-level directory structure capability or single level grouping option. It would be even better, if user could add some tags to files and see some sort of clickable tag list at the bottom of file manager and do quick filtering of files. Creation of tags could be achieved in the same view as title and description is currently, just that auto-complete option would be really nice.
Hi, is there a way to only render the File Manager into a view as per the 4th screenshot. What am i missing here?
Hello.
I'm using yii2-filemanager you're created. It's very helpful. But I have a problem:
The default mode when create thumbnail images is THUMBNAIL_OUTBOUND. But I want to change it to THUMBNAIL_INSET. I'm looking for a config but It didn't have a config about it. Hope you to help me! Thanks a lot.
Hi!
When images have been uploaded to the folder, they have following names:
Then images are not available in the file manager:
It would be great if there were possibility to upload files with cyrillic names, or had the opportunity to enable automatic file renaming, not only this:
Btw, thanx for the module 👍
And sorry for my english.
This commit change the view/file/filemanager.php and add this
if(file_exists(substr($model->getDefaultThumbUrl($this->params['moduleBundle']->baseUrl), 1))){
return Html::a(
Html::img(Yii::getAlias('@web').$model->getDefaultThumbUrl($this->params['moduleBundle']->baseUrl))
. '<span class="checked glyphicon glyphicon-check"></span>',
'#mediafile',
['data-key' => $key]
);
}
else{
return null;
}
This code simply break the module in my website now I can't visualize the images in advanced template.
I don't understand exactly the code but this don't work so must be reverted to the previous one.
Currently, file upload is very tedious, requires many, seemingly useless clicks to upload and confirm and return etc.
To upgrade user experience, I would like to suggest couple improvements:
Hi,
I have the file manager working within my frontend however when using the file input within the backend and selecting an image within the file manager I get the following error message in my console:
GET http://localhost:8888/backend/filemanager/file/info?id=89&strictThumb=original 500 (Internal Server Error)
I am also unable to upload images from the backend as I get the following message:
{"files":[{"url":null,"thumbnailUrl":"/backend/assets/b2588d8f/images/file.png","name":null,"type":null,"size":187011,"deleteUrl":"/backend/filemanager/file/delete","deleteType":"POST"}]}
Здравствуйте!
Этот менеджер создает папки для файлов вида "2014/12", но я хотел бы самостоятельно управлять этим путем. Например на конкретной странице мне нужно что бы путь был "post/1" или "product/23".
То есть я хочу раскладывать файлы не по датам, а по смыслу.
Как это сделать?
Hi.
I make "composer update" and tags functionality not working.
http://s013.radikal.ru/i324/1606/58/da1169001231.jpg
День добрый,
У меня возникла такая ситуация:
Я разрабатывал один сайт на локальной машине (Windows 8.1) и после того как выкатил его на сайт, то возникла ошибка: на бою система не нашла класс для TinyMCE виджета. Тогда я заметил, что в папке /vendor/pendalf89/yii2-filemanager/widgets/ файл называется TinyMce
Есть ли причина оставлять этот файл с таким именем?
Hello. I can't apply this migration on my production server:
MySQL version:
~$ mysql --version
mysql Ver 14.14 Distrib 5.5.36-34.0, for debian-linux-gnu (x86_64) using EditLine wrapper
Error I got when tried to apply migraion:
*** applying m141203_173402_create_filemanager_owners_table
create table filemanager_owners ...
Exception 'yii\db\Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
The SQL being executed was: CREATE TABLE `filemanager_owners` (
`mediafile_id` int(11) NOT NULL,
`owner_id` int(11) NOT NULL,
`owner` varchar(255) NOT NULL,
`owner_attribute` varchar(255) NOT NULL,
PRIMARY KEY (`mediafile_id`, `owner_id`, `owner`, `owner_attribute`)
)'
What I can do? I can't change server because it's my client's server.
First, I want to thank you and suggest an update.
Filemagener can be access by url without login.
I updated FileController function behaviors like this:
public function behaviors() { return [ 'access' => [ 'class' => \yii\filters\AccessControl::className(), 'only' => ['index', 'filemanager', 'uploadmanager', 'upload', 'update', 'delete','resize','info'], 'rules' => [ [ 'actions' => ['index', 'filemanager', 'uploadmanager', 'upload', 'update', 'delete','resize','info'], 'allow' => true, 'roles' => ['@'], ], ], ], 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['post'], 'update' => ['post'], ], ], ]; }
Hi. I can't install it via composer composer.phar require --prefer-dist pendalf89/yii2-filemanager "*"
which gives me following message:
Could not find package yii.bat at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability:
Can you help me to solve this issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.