0

I know you "can't" do this, but hoping there might be a way.. Editing the database directly could work if I knew exactly what needed to be edited. Basically I want to change a file type to image because as fileI cannot enforce dimensions (this is on a site that was converted from drupal 6 to drupal 7 and already has a fair bit of data)

2

Have you tried to peek inside a database via PhpMyAdmin ? For every field you have field_data_field and field_revision_field table, containing several columns depending on the field type. And also some config tables like field_config and field_config_instance, so many things to be aware of.

This is more an advice than a clear answer, meddling with database may be risky task.

But I do understand if you have large data collections, you might try to risk to hack database to convert to other field type.

Beware that field tables may be referenced by other tables / modules, so backup your db first and test on clone.

| improve this answer | |
2

I just wrote some code that should handle this for you in my Helper module: http://cgit.drupalcode.org/helper/tree/lib/FieldChangeHelper.php?h=7.x-1.x

FieldChangeHelper::changeType('my_file_field_name', 'image');

It should work fine for most simple cases and fields, but should be tested thoroughly. It also currently doesn't update any field formatters, so you'll want to review the display configuration for the field after running this.

| improve this answer | |
1

More of a pointer than a detailed response but another thing you could do is add a new temporary image field, migrate the data from your existing field into the new field, delete the old field, recreate the old field as an image field, migrate the data from the temporary field to the recreated field, delete the temporary field.

For the migration you could write a simple script to do it, or if you aren't big on coding you could try something like feeds or node_export (which does importing & exporting). These importing modules will do node updates as well as creation.

I'm sure you can do the change manually in the db as you are asking, you just want to be careful you don't miss something.

| improve this answer | |
  • I think this would be the best way to do it. Get it done once, and you will not have to worry about it again. – AyeshK Jun 14 '13 at 21:36
0

I just hack the database and found a table named "field_config" and modified the "type" and "module" column, from "file" to "image". It worked for me. Hope this could help you.

| improve this answer | |
0

Manually mirror/clone the content type in the UI with new field machine name and/or options, then use Covert Node module (excellent field mapping) on each node, or possibly with the Views Bulk Operation module. To mirror/clone the content type with a module try Content Type Clone, Field Tools or Bundle Copy. D7.

| improve this answer | |

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.