Personalize the drop area in Filepond

Is there a way to customize the filepond droparea by adding custom HTML with placeholder images to guide users on what kind of images should be uploaded and allow multiple uploads?

https://i.sstatic.net/VFGfJ.png

I attempted to add placeholders in an absolutely positioned container, but I faced challenges covering my custom element upon upload.

This is how Filepond is implemented in react :

...
    return (
      <div className="uploads">
        <div className="uploads__placeholders">{placeholderImages}</div>
        <FilePond
          ref={(ref) => (this.pond = ref)}
          files={this.state.files}
          labelIdle={""}
          allowMultiple={true}
          maxTotalFileSize={10485760}
          acceptedFileTypes={this.props.acceptedFileTypes}
          labelMaxTotalFileSize={"Total file size should be lesser than 10MB."}
          maxFiles={maxFilesAllowed}
          allowProcess={this.props.process ? this.props.process : true}
          imagePreviewHeight={135}
          //imagePreviewTransparencyIndicator={"grid"}
          server={{...}}
          onremovefile={(file) => {...}}
          oninit={(t) => {...}}
          onupdatefiles={(fileItems) => {...}}
        />
      </div>
    );
...

I created a custom wrapper and used CSS to align it on top of the filepond wrapper, although this might not be the most efficient solution.

Answer №1

To achieve the desired outcome, utilize the labelIdle feature in conjunction with the beforeAddFile option within your Filepond initialization. This allows for customization of the default HTML template by removing specific content prior to use.

If unsure about how to remove content in a react setting, consider implementing a similar approach in jQuery:

FilePond.parse(document.body);
const inputElement = document.querySelector('#file_upload');

FilePond.registerPlugin(FilePondPluginImagePreview);

const pond = FilePond.create(inputElement, {
  allowMultiple: true,
  imagePreviewHeight: 135,
  labelIdle: ` 
    <div style="width:100%;height:100%;">
    <p>
        Drag &amp; Drop your files or <span class="filepond--label-action" tabindex="0">Browse</span><br>
        Some samples to give you an idea :
      </p>
    </div>
    <div class="images" id="allImages">
       <div class="images_child">
          <img src="https://live.staticflickr.com/4561/38054606355_26429c884f_b.jpg">
       </div>
       <div class="images_child">
          <img src="https://live.staticflickr.com/4561/38054606355_26429c884f_b.jpg">
       </div>
       <div class="images_child">
          <img src="https://live.staticflickr.com/4561/38054606355_26429c884f_b.jpg">
       </div>
     </div>
  `,
  beforeAddFile (e) {
  $('#allImages').html('');
  }
});
.filepond--drop-label {
  background-color: #ECF7E9;
  height: auto!important;
}

.images {
  display: inline-block;
  padding: 0 5px;
}

.images_child {
  display: contents;
  padding: 0 5px;
  text-align: center;
}

.filepond--root * {
  height: auto;
  padding: 0 4px;
}

img {
  width: 25%;
  opacity: 0.8;
  filter: grayscale(100%);
  border-radius: 8px;
  cursor: pointer;
}


/* Responsive layout - makes a two column-layout instead of four columns */

@media screen and (max-width: 800px) {
  .column {
    flex: 50%;
    max-width: 50%;
  }
}


/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */

@media screen and (max-width: 600px) {
  .column {
    flex: 100%;
    max-width: 100%;
  }
}
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e5838c8980958a8b81c8958990828c8bc88c88848280c8959780938c8092a5d1cbd3cbd1">[email protected]</a>/dist/filepond-plugin-image-preview.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1c7c8cdc4d1cecfc5e1958f90968f90">[email protected]</a>/dist/filepond.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1c7c8cdc4d1cecfc5e1958f90968f90">[email protected]</a>/dist/filepond.css" />
<link rel="stylesheet" type="text/css" media="screen" href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2a4abaea7b2adaca6efb2aeb7a5abacefabafa3a5a7efb2b0a7b4aba7b582f6ecf4ecf6">[email protected]</a>/dist/filepond-plugin-image-preview.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script>

<input type="file" name='file' class='filepond' multiple id='file_upload' />

https://jsfiddle.net/d6e2nh93/

Disclaimers :

1) The complete CSS styling as shown in the image example is not provided here. Feel free to customize it based on your requirements.

2) While this solution may not directly address React-specific implementations, it serves as a useful guide for leveraging filepond functionalities effectively.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The text in my image is positioned away from the top

Hi there, I am new to exploring HTML and CSS and I have been trying to display some images and text on a webpage. My goal was to have the text appear next to the image, which is working fine. However, I am encountering an issue where the text aligns itself ...

When using React Final Form, the onBlur event can sometimes hinder the

What is the reason that validation does not work when an onBlur event is added, as shown in the example below? <Field name="firstName" validate={required}> {({ input, meta }) => ( <div> <label>First Name</label& ...

Using React.js to create a modal that includes ExpansionPanelDetails with a Checkbox feature

I am trying to achieve a specific visual effect with my code. Here is an example of the effect I want: https://i.stack.imgur.com/cJIxS.png However, the result I currently get looks like this: https://i.stack.imgur.com/547ND.png In the image provided, y ...

Tips for enabling autoplay for videos in Owl Carousel

I am facing an issue with implementing autoplay functionality for videos in an owl carousel. Despite trying different solutions found online, including this Owl Carousel VIDEO Autoplay doesn’t work, I haven't been able to make it work. Additionally, ...

Is the $ajax() function truly asynchronous when invoking a success callback?

I find myself in a state of confusion at the moment. The asynchronous ajax call I have set up includes a success callback function being passed in. ajax('PUT', 'some URL', successCallback, data); I notice that this callback is trigger ...

Is there a way to enable scanned data to be automatically inputted into a field without manual entry?

I am in the process of creating a user-friendly Android app for virtual inventory management. I want the application to streamline data input by automatically populating text fields upon scanning, eliminating the need for users to manually click on each fi ...

Navigating Assets within NodeJS Module

I'm facing a challenge with my NodeJS module that is designed to translate XML to HTML using an XSL file. The issue arises when I try to package the XSL file along with the rest of the module. Currently, the XSL file is located inside the source fold ...

arrangeable database table

I have created a large PHP generated table from a database and now the customer is requesting for it to be sortable. Below is a sample of the table's contents: ID BRAND KIND DESCRIPTION PRICE The customer wants to sort by price, and also have the a ...

Unable to access frame: Error - Unable to retrieve 'add' property from undefined

I am working on customizing the chatbot functionality for my website built with Nuxt.js. I want the chatbot to display on certain pages while remaining hidden on others. Unfortunately, I encountered an issue when trying to hide it on specific pages. To im ...

Mysterious attributes of angular 6's <table mat-table> tag

This particular question regarding the angular material table has not been duplicated in any other discussions. Other similar questions pertain to angular versions 2-5, not version 6 The issue I am encountering is as follows: Can't bind to 'dat ...

Quickest method for deriving a boolean value from multiple boolean inputs

Within a document, the keys isOccupied and vacant are being destructured. const { isOccupied, vacant } = doc || {}; boolDetermination = (isOccupied, vacant) => { if (isOccupied && isOccupied === vacant) { < --- Return isOccupied value ...

Storing a single JavaScript array in separate arrays depending on a specific condition

I have a JavaScript array variable where each element is an object with values like: {"ID":10075,"SPECIALIZATIONID":"17","PRESPCIALIZATIONID":11,"GROUPID":1} The entire JSON.stringify value looks like this: "[{"ID":10075,"SPECIALIZATIONID":"17","PRESP ...

PHTML file IIS handler

I was surprised by the lack of online results when searching for a solution to my issue. In my local PHP project, I am encountering problems with PHTML files not being parsed correctly by IIS. The 'phtml' type is not included in the module mappin ...

Can you interact with a node within an Electron application even if the node integration feature is not enabled?

I have an electron app created with vanilla electron. (using npx create-electron-app ......) Can I use const electron = require("electron"); with nodeintegration:true? The library I'm using does not support nodeintegration:true, but my scr ...

Creating a dynamic div with various paragraphs using only Javascript

My goal is to dynamically generate paragraphs with their respective icons inside individual div elements. For instance, if the service API returns 30 items, I will create 30 div elements with the class "tile". However, if only one item is returned, then I ...

Efficient State Management with React-Redux for Streamlined HTTP Requests

In the process of developing a React-Redux application, I have encountered a situation where I need to display a cancel button while a specific HTTP request is ongoing. Upon successful execution of the request, the UI should display the results. If the use ...

ExtJs encounters missing files in directory - Error: Module '<path>modern-app-3 ode_modules@senchaextpackage.json' not found

I am currently in the process of setting up a new ExtJs project by following the instructions provided here. Upon completing the installation of ext-gen, I proceeded to create a new app using the command ext-gen app -a -t moderndesktop -n ModernApp3, but ...

No matter what I do, I can't seem to stop refreshing the page. I've attempted to prevent default, stop propagation, and even tried using

Below is the code I have written for a login page: import { useState } from "react"; import IsEmail from "isemail"; import { useRouter } from "next/router"; import m from "../library/magic-client"; import { useEffect ...

Iterate through a jQuery function to retrieve values from checkboxes starting from the 4th one that has been clicked

I am currently using a loop in a form to calculate the total price of a product based on user selections. However, I have encountered a challenging task where certain checkbox groups have specific rules. For instance, group A should only contribute to the ...

Obtain consistent outcomes by entering identical data in both Ajax and PHP

My code takes a number input in a <textarea>, then uses AJAX to validate it randomly with PHP (using rand()). The validated number is returned along with the words correct or incorrect to a <div> in HTML. The issue is that if the same number i ...