A small plugin for Frappe that adds the support of customizations to the attach control.
- Requirements
- Setup
- Usage
- Available Field Options
- Available JavaScript Methods
- Supported Fields
- Issues
- Contributors
- License
- Frappe >= v12.0.0
Do not forget to replace [sitename] with the name of your site in all commands.
- Go to bench directory
cd ~/frappe-bench
- Get plugin from Github
(Required only once)
bench get-app https://github.com/kid1194/frappe-better-attach-control
- Build plugin
(Required only once)
bench build --app frappe_better_attach_control
- Install plugin on a specific site
bench --site [sitename] install-app frappe_better_attach_control
- Check the usage section below
- Go to app directory
cd ~/frappe-bench/apps/frappe_better_attach_control
- Get updates from Github
git pull
- Go to bench directory
cd ~/frappe-bench
- Build plugin
bench build --app frappe_better_attach_control
- Update a specific site
bench --site [sitename] migrate
- (Optional) Restart bench
bench restart
- Go to bench directory
cd ~/frappe-bench
- Uninstall plugin from a specific site
bench --site [sitename] uninstall-app frappe_better_attach_control
- Remove plugin from bench
bench remove-app frappe_better_attach_control
- (Optional) Restart bench
bench restart
- Go to Customization > Customize Form
- Enter the form type/name (Ex: 'User')
- Scroll down to the form fields area and create an Attach or Attach Image field or edit an existing custom field
- In the options property of the field, add a JSON object of the customizations you want. Example:
{"allowed_file_types": ["jpg", "png", "gif"]}
ℹ️ Note: You can't modify the original fields of a doctype, so create a new field or clone and modify the entire doctype.
Option | Description |
---|---|
upload_notes |
Upload text to be displayed. - Example: "Only allowed to upload images and video, with maximum size of 2MB" - Default: "" |
allow_multiple |
Allow multiple uploads. - Default: false |
max_file_size |
Maximum file size (in bytes) that is allowed to be uploaded. - Example: 2048 for 2KB - Default: Value of maximum file size in Frappe's settings |
allowed_file_types |
Array of allowed file types (mimes) or extensions to upload. - Example: ["image/*", "video/*", ".pdf", ".doc"] - Default: null or ["image/*"] |
max_number_of_files |
Maximum number of files allowed to be uploaded if multiple upload is allowed. - Example: 4 - Default: Value of maximum attachments set for the doctype |
crop_image_aspect_ratio |
Crop aspect ratio for images (Frappe >= v14.0.0). - Example: 1 or 16/9 or 4/3 - Default: null |
as_public |
Force uploads to be saved in public folder. - Default: false |
allow_reload |
Allow reloading attachments (Frappe >= v13.0.0). ℹ️ Affect the visibility of the reload button.ℹ️ - Default: true |
allow_remove |
Allow removing and clearing attachments. ℹ️ Affect the visibility of the remove and clear buttons.ℹ️ - Default: true |
Method | Description |
---|---|
enable_reload() |
Allow reloading attachments and show the reload button (Frappe >= v13.0.0). |
disable_reload() |
Deny reloading attachments and hide reload button (Frappe >= v13.0.0). |
enable_remove() |
Allow removing and clearing attachments and show the clear and remove buttons. |
disable_remove() |
Deny removing and clearing attachments and hide the clear and remove buttons. |
show_files() |
Show the list of uploaded files in a dialog (Only when multiple files is allowed). |
- Attach
- Attach Image
If you find bug in the plugin, please create a bug report and let us know about it.
The list of people who deserves more than a simple thank you.
- CA. B.C.Chechani (Testing & Debugging)
This repository has been released under the MIT License.