Title: Sanitisation file field
Last modified: August 31, 2016

---

# Sanitisation file field

 *  Resolved [andreyfilippov](https://wordpress.org/support/users/andreyfilippov/)
 * (@andreyfilippov)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/sanitisation-file-field/)
 * Hi,
 * I need to save attachment data for using them network wide in a multisite. I 
   tried implementing this via `sanitization_cb` callback function. But when using
   a callback function for file type fields it’s impossible to change the file in
   the dashboard. Even if the callback function do nothing.
 * Link with the code example:
    [http://joxi.ru/823gNV9h6gQYw2](http://joxi.ru/823gNV9h6gQYw2)
 * Able to change another image, but cannot save, eg:
    [http://joxi.ru/82QWRvZI1KkDor](http://joxi.ru/82QWRvZI1KkDor)
 * Is it possible to do this via callback function, or I have to use filter instead?
 * Thanks.
 * [https://wordpress.org/plugins/cmb2/](https://wordpress.org/plugins/cmb2/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 1 month ago](https://wordpress.org/support/topic/sanitisation-file-field/#post-7199751)
 * I’m not sure multisite has its own media library so where you end up saving the
   images is a bit up in the air. Probably not directly answering the question, 
   but it’s something to make note of for sure.
 * Out of curiosity, is it saving as expected in single site?
 *  Thread Starter [andreyfilippov](https://wordpress.org/support/users/andreyfilippov/)
 * (@andreyfilippov)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/sanitisation-file-field/#post-7199762)
 * The problem is actually not multisiting related. Just used the situation as an
   example.
 * So, yeah, the problem exists in a single site too. I think it’s related to the
   attachment id, which is not used in the callback, though used in CMB2 object.
 * P. S. Using “cmb2_override_{$a[‘field_id’]}_meta_value” filter for my needs 🙂
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 1 month ago](https://wordpress.org/support/topic/sanitisation-file-field/#post-7199785)
 * If I recall right, Justin passes in the attachment IDs as an array index.
 * The images aren’t coming up for me at the moment, but if any of the passed in
   values are arrays, I’d check the indexes on them and see if those match

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Sanitisation file field’ is closed to new replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

## Tags

 * [attachment](https://wordpress.org/support/topic-tag/attachment/)
 * [file field](https://wordpress.org/support/topic-tag/file-field/)

 * 3 replies
 * 2 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/sanitisation-file-field/#post-7199785)
 * Status: resolved