0

I am trying to create an image gallery in my drupal site from the backend. Also I want to add images to existing content types since there are large number of nodes and attaching image to each of them from the front end is not feasible. What I have understood follows here:

The database contains the table named files that consists of path and type of each file uploaded from fronted. The fid corresponding to each of these paths is used in corresponding content type table to produce images at required node.

Plase tell me if this approach is wrong:

I wanted to upload images in bulk and add image names and there path in the files table as well as corresponding fid's in the content type tables.

But this does not work. Can someone help me with this. Have I analysed it wrongly?

  • 1
    Please don't crosspost; we can migrate questions. – Ripped Off Mar 15 '12 at 12:25
  • sorry to do that but i was told that this question belonged to stackexchange so i posted here. Is there any solution anyone can provide. Any help would be highly appreciated. Thanks – user1153986 Mar 16 '12 at 4:30
0

I spent some time in understanding how Drupal 6 retrieves images to show on front-end. Since drupal is heavily database intensive, all the files and images are retrieved from the database itself.

If you are using CCK in your site, you must have created image fields for some content types. Now if you open the database and check the table for respective content type, you will find that there are three columns created for each image cck field namely field_name_fid,field_name_list,field_name_data .

The field "field_name_fid" is the key field that maps images to this content type. The fid is the key that is matched to the fid of the table "files". If you open this table, you will find that the primary key of this table i.e fid is used to map images throughout Drupal content.

Here comes the solution

  1. Upload an image from the frontend to test where is your file saved physically in you drupal directory. For every image uploaded to any node from front-end there will be an entry in the files table with its filename, filepath, filemime, file size, status and timestamp.
  2. The fields that you should take care about in the files table are filename, uid, filepath, filemime, and status.
  3. All you have to do is, Place all your files in that physical location.
  4. Run SQL queries to first fill all the fields stated in #2. and match the fid of files table to the field_name_fid of respective content type.

And you are done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.