Title: Read from S3
Last modified: August 20, 2016

---

# Read from S3

 *  [fredriksundstrom](https://wordpress.org/support/users/fredriksundstrom/)
 * (@fredriksundstrom)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/read-from-s3/)
 * Hi!
 * I’ve been looking around the web and maybe I’m not aware of the right terms to
   search for, but I’ve been looking for a way to keep the Media Library in its 
   entirety on Amazon S3. The reason is I’m hosting with Heroku/Appfog which doesn’t
   allow me to store the files on the web server and deletes them on every application
   restart.
 * Is this included or not? How do I set it up? I can serve the files from S3 etc,
   works just great. But they’re all broken in the WordPress admin.
 * I wrote a small plugin myself to give me the ability to do this, but it’s you
   know… It’s a hack right now, I’d much rather see it in the plugin! 🙂
 * Here’s the small plugin which gives me the stuff I need at least:
 *     ```
       add_filter( 'wp_get_attachment_image_attributes', 's3_reads_wp_get_attachment_image_attributes' );
       function s3_reads_wp_get_attachment_image_attributes($array)
       {
         $array['src'] = s3_reads_replace_image_url($array['src']);
         return $array;
       }
   
       add_filter( 'wp_get_attachment_url', 's3_reads_wp_get_attachment_url' );
       function s3_reads_wp_get_attachment_url($url)
       {
         $url = s3_reads_replace_image_url($url);
         return $url;
       }
   
       function s3_reads_replace_image_url($url)
       {
         $config = w3_instance('W3_Config');
         $bucket = $config->get_string('cdn.s3.bucket');
   
         $siteurl = get_site_url();
   
         return str_replace($siteurl, "http://{$bucket}.s3.amazonaws.com", $url);
       }
       ```
   
 * [http://wordpress.org/extend/plugins/w3-total-cache/](http://wordpress.org/extend/plugins/w3-total-cache/)

The topic ‘Read from S3’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [fredriksundstrom](https://wordpress.org/support/users/fredriksundstrom/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/read-from-s3/)
 * Status: not resolved