What Happened to Red "X" (Delete Uploaded File)? [RESOLVED]

Good Day,

We’re using a Gravity Form that allows visitors to upload files. When a file is uploaded, the visitor is given a chance to delete the file by clicking on a “Trash Can” dashicon.

The above is forcing us to use the WordPress dashicon file, /wp-includes/css/dashicons.min.css, which adds a heavy payload (57.6 KB) to our affected page.

We would like to dequeue WordPress’ dashicon file and use instead a native Gravity Form symbol (say, a red “X”) to perform the same file delete function. This would make our page a lot lighter.

Can anyone tell us if such an option (or code snippet) exists? We believe there used to be a red “X” available at one time, but perhaps a recent Gravity Forms update delete it (?)

Thank you!

Hi Jonathan. There is a red X image in the plugin. It’s located here:

wp-content/plugins/gravityforms/images/delete.png

You can use the gform_field_upload_markup to change back to using that image. See the example code here:

1 Like

Can you post your code again without the backticks? It really got mangled and I can’t tell if there is anything wrong with it in use, or if it’s only mangled here.

You can use three backticks on a new line to make a whole block code, then close with three backticks on a new line when you’re done. Or, paste the code in and then click the code icon in the formatting bar, which looks like this:

</>

First, there is a JavaScript version and a PHP version. Both need to be used.

Second, the actual form ID and field ID are not part of the PHP code. The parameters $form_id and $field_id should be left as is. They are passed in to the filter: you don’t set them.

Finally, the red X was previously used to be the delete icon, but it was confusing to some users, thinking it meant there was an error. For that reason, the red X was changed to a trash icon.

The use of dashicons is currently being evaluated and may be changed in a future version, due to the weight of that file.

1 Like

Update

Issue solved. We used the both the JS and PHP codes referenced by @chrishajer as is.

The JS code was added to the header of our affected Gravity Forms page and the PHP code was added to our site via the plugin, Code Snippets.

Everything now working great. The best part is we got rid of the pesky Dashicons JS file (58 KB)!

Cheers!

1 Like

1 Like