Code Monkey home page Code Monkey logo

la-filepond's Introduction

filepond for laravel-admin

Travis (.com) style ci download lincense LICENSE Pull request welcome

About

Filepondis a flexible and fun JavaScript file upload library, that can upload anything you throw at it, optimizes images for faster uploads, and offers a great, accessible, silky smooth user experience. Filepond for laravel-admin is laravel-admin extention base on it.

Why

laravel-admin's upload item is hard to use and more complex, and slowly upload while more multiple files, this is a bad user experience. Filepond upload by ajax, suitable for multiple file upload.

Demo

Install

first, install laravel-admin, and run below command.

composer require tiderjian/la-filepond

run laravel-admin extention import.

php artisan admin:import filepond

Config

find out the extensions segment in the config/admin.php,add filepond config

'extensions' => [
    'filepond' => [
        // enable or disable the extension
        'enable' => true,
        // atuo delete the uploaded files(default false)
        'autodelete' => true
    ]
]

Usage

//image upload
$form->filepondImage(@database column, @label)
//file upload
$form->filepondFile(@database column, @label)

//multiple images upload
$form->filepondImage(@database column, @label)->multiple()
//multiple files upload
$form->filepondFile(@database column, @label)->multiple()

//ps:multiple upload save to database in json,must set the casts to json on the model.
protected $casts = [
    'images' => 'json',
    'files'  => 'json',
];

//set required
$form->filepondImage(@database column, @label)->rules('required')

//set file type that can be uploaded.
$form->filepondFile(@database column, @label)->mineType(['application/msword', 'application/pdf'])
$form->filepondFile(@database column, @label)->mineType('application/msword')

//set max file size, unit: KB
$form->filepondFile(@database column, @label)->size(30)

extension

You can extend it by youself, here is a sample that extend a image size validate plugin.

  1. download filepond-plugin-image-validate-size,add to public/vendor/laravel-admin-ext/la-filepond/js

  2. add to app/Admin/bootstrap.php

\Encore\Admin\Admin::booting(function(){
    \Qs\La\Filepond\File::extendPluginJs(['/vendor/laravel-admin-ext/la-filepond/js/filepond-plugin-image-validate-size.min.js']);
    \Qs\La\Filepond\File::extendPlugin('FilePondPluginImageValidateSize');
    //use the \Qs\La\Filepond\File::extendPluginCss function to add css file
});
  1. find out the pulgin document, and add config as you like
//imageValidateSizeMinWidth、imageValidateSizeMaxWidth is the config keys
$form->filepondImage('images', 'images')->multiple()->options(['imageValidateSizeMinWidth' => 200, 'imageValidateSizeMaxWidth' => 400]);

lincense

MIT License AND 996ICU License

la-filepond's People

Contributors

jianminlee avatar tiderjian avatar

Stargazers

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

Watchers

 avatar  avatar

la-filepond's Issues

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.