Support » Plugin: WP Offload S3 Lite » How to update older Image URLs?

Viewing 15 replies - 1 through 15 (of 16 total)
  • yup, same question here.
    moving older image to s3
    thanks in advance

    Hey, I just ran across this concern as well and I found a solution by using a very convenient plugin called Regenerate Thumbnails Basically all you have to do is:

    1. Install and activate the plugin
    2. Locate the tool within the Tools admin menu link
    3. Click on the Regenerate All Thumbnails button
    4. Wait until the process is completed

    Keep in mind the process can take quite some time to complete depending on the amount of images you have in your media library, so make sure you will maintain a steady and strong connection to the Internet during the process and that you do not close the window that is running the regeneration script. Also make sure your settings for Amazon S3 and Cloudfront are correct and are working before starting the regeneration process.

    This will not regenerate custom thumbnails that are not registered as being a valid image size in your theme and plugins, so as long as the developers of your theme and plugins followed the standard thumbnail creation process as briefly outlined here then you will be all set. Don’t worry if the images were invalidly created, if the plugin is able to handle output and storage of the image urls appropriately you won’t lose them since none of those images would be overwritten.

    Hope this helps.

    Hey @sforsberg,

    That is a good idea, any other ideas on what you would do for media which isn’t images, such as pdf’s etc ?


    any solutions for non images especially when using older multi-site?

    redirect options?

    Not sure if this will help, but this is how I think we are going to deal with this.

    For images already placed in posts and pages, we’ve used a redirect in our .htaccess file. for our regular non-multi site wp, we’ve used:
    RewriteRule ^wp-content/uploads/(.*)$$1 [L]
    of course your path might be different.

    For our wp-mu site we’ve created our own ms-files.php to point to our s3 path and then pointed to it via .htaccess ala this:
    RewriteRule ^(.*/)?files/(.*) wp-content/mu-plugins/vital-scripts/ourown-ms-files.php?file=$2 [L]

    in that file basically we’ve replaced:
    $file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET[ 'file' ] );
    $file = "{$bucket}{$blog_id}/files" . '/' . str_replace( '..', '', $_GET[ 'file' ] ) ;
    we also removed/updated some of the code to work with S3.

    This is the down and dirty that we’ve done but since the plugin creates a global object of
    $as3cf you could use that to get your bucket and other features set via the plugin to use in various urls.

    So far it seems to be working.

    Not implemented but and idea for older images that haven’t been place into posts yet, you could use the wp_get_attachment_url filter to filter the url before it gets inserted. Doing it on the fly would basically eliminate the need to update the db. Just a thought.


    Plugin Author Brad Touesnard


    I’d probably use to update those URLs.

    I used the plugin Velvet Blues Update URLs and it worked great for changing the URLs in my posts and pages. But when I am in my WP admin and look at the media library, all of the images that I transferred myself to my S3 bucket don’t show thumbnails. I’ll have to try the regenerate thumbnails to see if that does it. I can probably make changes in my database, but . . .

    Samb_nz–the velvet blues plugin should work for other files as well.

    A thumbnail regeneration plugin won’t work for this because it looks for the image in the original path.

    Info needs to be placed in the database, but I need help with that. Brad, I found this link you gave in another thread to the code that your plugin adds to the database. Can you tell me what the sql command would be to add the meta_key and meta_value in the wp_postmeta table in the database for the old media files?

    @tracibunkers I also ended up using an .htaccess file in the wp-uploads dir that just redirects to the s3 bucket, and manually uploaded all my old media. That way I didn’t have to alter anything in wordpress, then this plugin takes care of any new files.

    @samb_nz So, you did the redirect for the links instead of changing them? (I already changed my links with the velvet blues plugin). The only problem I’m having is in the admin for my media library, the thumbnails don’t show up for the old files that I manually moved to my S3 bucket. They show up on the posts fine, just not in the admin. It’s only a problem if I want to use an older image in a post.

    Yeah @tracibunkers,

    I used the .htaccess, which meant everything worked as normal in the wordpress admin.

    And I JUST realized that none of the thumbnails on my blog show up. SO if someone does a search, none of the results have thumbnails–just a blank box where the image should be. Dang.

    I figured it out:

    1. With some basic SQL knowledge you can determine all posts of post type attachment that do not have an entry with the meta_key “amazonS3_info” in the table wp_postmeta.
    2. Extract the file name of each attachment from the old guid in wp_posts.
    3. Add for each attachment a line like the following to functions.php and refresh the website: add_post_meta( 2868, 'amazonS3_info', array('bucket' => "your-bucket", 'key' => "path/to/media/in/bucket"));

    In addition to the previously mentioned solution you should dump the database and replace all old URLs that point to the media files, e.g:
    sed 's/http:\/\/\/media/http:\/\/\/media/g' old.sql > new.sql

    Plugin Author Brad Touesnard


    I’d be careful doing find & replace on SQL like that. You should use instead.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘How to update older Image URLs?’ is closed to new replies.