• 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/

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