Migrating Image Attach to Image CCK

Image attach module is good and quick way for having one image attached per node. But after having used on your site, later you might realize that you need more than one image per node, and you want to use CCK image field for it.

The problem is that you already have many images attached to your nodes.

Don't despair there is a quick and easy way to migrate your image attach images to your new CCK field.

Just fire the following SQL and it will migrate all your images from image_attach to image CCK, make sure you put any database prefix you might have, and also replace the table for image field with your table for image field.

  1. insert into content_field_image
  2. SELECT ia.nid, 0, ia.nid,f.fid, f.filepath, f.filepath
  3. FROM image_attach ia, files f
  4. where ia.iid = f.nid and f.filename='_original'