Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I've got a content type with a field who contains a default value. In this default value there is an image and I would like to change the source of this image to all the existing contents.

from <img src="sites/file/image.jpg" /> to <img src="sites/file/images/image.jpg" />

How can apply this to the existing contents?

Thanks in advance.

share|improve this question

1 Answer

up vote 1 down vote accepted

You may do a SQL query to update the field.

Table: field_data_field_NAME

Column: field_NAME_value

Table: field_revision_field_NAME

Column: field_NAME_value

UPDATE `db_name`.`field_data_field_NAME` SET field_NAME_value = replace(field_NAME_value, '/sites/files', '/sites/files/images');

You may want to update the revision table of the field as well

UPDATE `db_name`.`field_revision_field_NAME` SET field_cc_NAME_value = replace(field_NAME_value, '/sites/files', '/sites/files/images');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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