Standard file fields can be configured to include a description field to go along with each file. Image fields can be configured to include alt and title fields for each image.

These properties are already exported correctly by node export. When file fields are imported, the values for these properties are missing.


milesw’s picture

Status: Active » Needs review
1.52 KB

Small change to retain the exported file field values.

milesw’s picture

Without the accidental newline addition.

brettbirschbach’s picture

Thanks for your patch miles! Just applied it on my project so that imported image fields preserve title/alt

cosmicdreams’s picture

Issue summary: View changes

I have found that this patch does keep the values, but the values are not saved.

The specific problem I'm trying to solve is to keep the image titles or captions that I am importing.

cosmicdreams’s picture

The change also needs to be in _node_export_file_field_import_file(&$file), which overrites the incoming file data if the file already exists.

cosmicdreams’s picture

I ultimately had to do this in node_export.module: _node_export_file_field_import_file(&$file)

// Keep existing file if it exists already at this uri (see also #1023254)
    // Issue #1058750.
    $query = db_select('file_managed', 'f')
        ->fields('f', array('fid'))
        ->condition('uri', $file->uri)

    if (!empty($query)) {
      watchdog('node_export', 'kept existing managed file at uri "%uri"', array('%uri' => $file->uri), WATCHDOG_NOTICE);
      $existing_file = file_load(array_shift($query));

      if(!empty($file->title)) {
        $existing_file->title = $file->title;

      $file = $existing_file;

  • danielb committed 0e2e640 on 7.x-3.x authored by milesw
    Issue #1868450 by milesw: File fields lose properties specific to the...
danielb’s picture

Status: Needs review » Closed (fixed)