Giter Club home page Giter Club logo

yii2-file-input-widget's Introduction

FileInput Widget for Yii2

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

This widget allows to make use of the great File Input Plugin that Arnold Daniels developed to enhance our Bootstrap experience.

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require 2amigos/yii2-file-input-widget:~1.0

or add

"2amigos/yii2-file-input-widget": "~1.0"

to the require section of your composer.json file.

Then, Add to your configuration file, the following to your components section:

'i18n' => [
      'translations' => [
          'file-input*' => [
              'class' => 'yii\i18n\PhpMessageSource',
              'basePath' => dirname(__FILE__).'/../vendor/2amigos/yii2-file-input-widget/src/messages/',
          ],
      ],
  ],

If a translation is missing, feel free to make a PR and I will merge it.

Usage

Using a model:

use dosamigos\fileinput\FileInput;

<?=FileInput::widget([
    'model' => $model,
    'attribute' => 'image', // image is the attribute
    // using STYLE_IMAGE allows me to display an image. Cool to display previously
    // uploaded images
    'thumbnail' => $model->getAvatarImage(),
    'style' => FileInput::STYLE_IMAGE
]);?>

Update

We have included the improved and multiple file upload version from Krajee.


<?= $form->field($model, 'code')->widget(\dosamigos\fileinput\BootstrapFileInput::className(), [
    'options' => ['accept' => 'image/*', 'multiple' => true],
    'clientOptions' => [
        'previewFileType' => 'text',
        'browseClass' => 'btn btn-success',
        'uploadClass' => 'btn btn-info',
        'removeClass' => 'btn btn-danger',
        'removeIcon' => '<i class="glyphicon glyphicon-trash"></i> '
    ]
]);?>

For further information regarding Krajee's version, please visit its site.

Testing

$ ./vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The BSD License (BSD). Please see License File for more information.


web development has never been so fun
www.2amigos.us

yii2-file-input-widget's People

Contributors

amigo-tabin avatar creocoder avatar dd174 avatar karataserkan avatar kuangjy2 avatar m8rge avatar pawelkania avatar skiptirengu avatar srdjan92 avatar tonydspaniard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-file-input-widget's Issues

customParameter is missing

customParameter is missing from the current installation. Do I need to use any other version for this?

image

Bootstrap4 problems installing via composer.

Dear, I install via composer as suggested by the repository cover, but apparently it does not install the latest version of it, I have problems when rendering the views with Bootstrap4 which is how I currently have my project. The code of the assets of the installed version is this:

FileInputAsset.php

<?php
/**
 * @link https://github.com/2amigos/yii2-file-input-widget
 *
 * @copyright Copyright (c) 2013-2015 2amigOS! Consulting Group LLC
 * @license http://opensource.org/licenses/BSD-3-Clause
 */

namespace dosamigos\fileinput;

use yii\web\AssetBundle;

/**
 * FileInputAsset.
 *
 * @author Antonio Ramirez <[email protected]>
 *
 * @link http://www.ramirezcobos.com/
 * @link http://www.2amigos.us/
 */
class FileInputAsset extends AssetBundle
{
    public $sourcePath = '@vendor/jasny/bootstrap/dist';
    public $css = [
        'css/jasny-bootstrap.css',
    ];
    public $js = [
        'js/jasny-bootstrap.js',
    ];
    public $depends = [
        'yii\bootstrap\BootstrapPluginAsset',
    ];
}

And this differs from the last commit you have in your file: src/FileInputAsset.php

The composer.json file in your package is as follows: composer.json

And in the file that you download when it is installed is the following:

{
    "name": "2amigos/yii2-file-input-widget",
    "description": "Jasny file input widget for the Yii framework",
    "keywords": [
        "2amigos",
        "yii",
        "yii2",
        "yii 2",
        "widget",
        "file input"
    ],
    "type": "yii2-extension",
    "license": "BSD-3-Clause",
    "homepage": "https://github.com/2amigos//yii2-file-input-widget",
    "authors": [
        {
            "name": "2amigOS! Consulting Group",
            "email": "[email protected]",
            "homepage": "http://2amigos.us",
            "role": "Developer"
        }
    ],
    "require": {
        "yiisoft/yii2": "~2.0.0",
        "yiisoft/yii2-bootstrap": "~2.0.0",
        "jasny/bootstrap": "~3.1.0",
        "kartik-v/bootstrap-fileinput": "~4.1.0"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0"
    },
    "autoload": {
        "psr-4": {
            "dosamigos\\fileinput\\": "src"
        }
    },
    "extra": {
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        },
        "branch-alias": {
            "dev-master": "1.0-dev"
        }
    }
}

If you observe, it does not have the bootstrap4 requirement, I can solve it by modifying the assets files, but it does not seem like a verbose way, tell me if I can install in another way that is not unzipping the package so it is loaded in my dependencies. It's a great extension!

I await your comments, greetings!

Image Array

Hi, i am try to upload more than 1 image in same time and try to get that images in Controller.
But array didn't get all images only get last image.
Please help for sort out this

Bug in BootstrapFileInput

If clientEvents is non-empty, the array $js is set to [](line 69). Consequently, the Javascript code to initialize the file input is cleared! The only Javascript in the HTML are the event handlers.

getAvatarImage in the example

First of all, it is not a bug or an issue. It is just a question.

Could you give a little hint about a tool or an helper that could be used in the model to build a model's method performs getAvatarImage() functionality?

can you tell me how to set the max image height and width , and also the max size of image ? :question

FileUpload::widget([
          'model' => $photo_model,
          'attribute' => 'image',
          'url' => ['ui/photo_upload'], // your url, this is just for demo purposes,
          'clientOptions' => [
              'maxFileSize' => 5000000,
              'imageMaxWidth'=>1920,
              'imageMaxHeight'=>1080,
              'imageMinWidth'=>500,
              'imageMinHeight'=>500,
              'imageQuality'=>70,
          ],
]);

Hi , could you teach me how to limit the image size ? I put these parameters in clientOptions . but it not work.

Could you help me how to set it ? thanks !

Sample of usage not working

Hi,

I think, based upon your definitions in composer.json and the namespace related stuff, its not possible to implement your extension as described in readme.md :( Pls can you correct it?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.