Title: Stop specific file offloading
Last modified: April 9, 2020

---

# Stop specific file offloading

 *  [adventurequalifications](https://wordpress.org/support/users/adventurequalifications/)
 * (@adventurequalifications)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/stop-specific-file-offloading/)
 * Hi – I am brand new to this and am trying to self teach whilst in lockdown.
 * I am trying to stop specific files from offloaded by WP Offload Media as they
   are needed on the server. I am using WP Offload Media Tweaks, but I am new to
   coding. As in this is my first try…
 * I need any file that has KEEP in the filename from offloading and it must stay
   on the server. What I have been trying does not work. Any ideas? The code I tried
   in the tweaks plugin after lots of internet searching is:
 *  function pre_upload_attachment( $abort, $post_id, $metadata ) {
 *  $file = get_post_meta( $post_id, ‘_wp_attached_file’, true );
    $filename = is_string(
   $file ) ? pathinfo( $file, PATHINFO_FILENAME ) : false; if ( is_string( $filename)&&
   in_array( $filename, array( ‘KEEP’ ) ) ) { $abort = true; }
 * What am I doing wrong?
    Thanx Andrew

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [ianmjones](https://wordpress.org/support/users/ianmjones/)
 * (@ianmjones)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/stop-specific-file-offloading/#post-12688572)
 * Try something like…
 *     ```
       function pre_upload_attachment( $abort, $post_id, $metadata ) {
           $file = get_post_meta( $post_id, '_wp_attached_file', true );
   
           if ( is_string( $file ) && false !== strpos( $file, 'KEEP' ) ) {
               $abort = true;
           }
   
           return $abort;
       }
       ```
   
 * Make sure to uncomment the associated `add_filter( 'as3cf_pre_upload_attachment'...`
   line in the Tweaks plugin’s constructor.

Viewing 1 replies (of 1 total)

The topic ‘Stop specific file offloading’ is closed to new replies.

 * ![](https://ps.w.org/amazon-s3-and-cloudfront/assets/icon-256x256.jpg?rev=1809890)
 * [WP Offload Media Lite for Amazon S3, DigitalOcean Spaces, and Google Cloud Storage](https://wordpress.org/plugins/amazon-s3-and-cloudfront/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amazon-s3-and-cloudfront/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/)
 * [Active Topics](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [ianmjones](https://wordpress.org/support/users/ianmjones/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/stop-specific-file-offloading/#post-12688572)
 * Status: not resolved