Support » Plugins » [Plugin: Custom Field Images] Moving a site, losing CFI

  • Resolved mjjwatson


    Hi, I’ve noticed that, when moving domains of a site, all CFI data is disappearing.

    I’m in the process of uploading from a local host. My normal technique for moving wordpress is to export an .sql, look for “http://localhost/mysite” and replace with “” and then look for the full path, “applications/MAMP/www/mysite”, for example, and replace with the new full path.

    This tends to work for everything I’ve moved in the past. But with CFI, the moved version of the blog has all CFI fields as empty. The images they used to link to are still present in the media library.

    Any clues as to why this is happening would really make me relieved. I can’t get my head around it, and I’m moving a site with about 1000+ thumbnail CFIs! *gulp*

    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Check the wp_postmeta table for meta_key = ‘_cfi_image’ (the meta_value will be serialized).

    Hi Scribu,

    Thanks for the reply, I’ve got to the bottom of it, it’s all to do with me not fully comprehending serialized data types.

    If anyone else needs help with this, this site explains it brilliantly.

    As a follow up question though, is there any quick, non-manual way to change the string-length values in the serialized data for the new domain? I’m guessing as you developed the plug-in you may well have moved it around a bit from server to server in your time!

    Thanks again.

    The safest way to work with serialized data is through PHP. This script should do it:

    function manipulate_cfi_row($fields) {
      // whatever you want to do here:
      $fields['url'] = str_replace('old', 'new', $fields['url']);
      return $fields;
    function manipulate_cfi_data() {
      global $wpdb;
      $data = $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_cfi_image'");
      foreach ( $data as $row ) {
        $new_data = manipulate_cfi_row(unserialize($row->meta_value));
        update_post_meta($row->post_id, '_cfi_image', $new_data);

    Not tested. Make a backup before you run it!

    Absolutely awesome. It totally did the trick, and hey, I’ve learnt something new today too.

    I’ve passed you some paypal money to say thanks.

    I use cfi plugin in a few of my wordpress jobs for clients, and it’s really come in handy.

    Thanks again man.

    You’re welcome. 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Custom Field Images] Moving a site, losing CFI’ is closed to new replies.