Browse Source

Preserve image alt/title attributes.

Frederic G. MARAND 7 years ago
parent
commit
095fdf8735
1 changed files with 6 additions and 7 deletions
  1. 6 7
      src/Plugin/migrate/source/ReinstallSourceBase.php

+ 6 - 7
src/Plugin/migrate/source/ReinstallSourceBase.php

@@ -111,7 +111,9 @@ class ReinstallSourceBase extends SourcePluginBase implements ContainerFactoryPl
         $item = reset($item_list);
       }
 
-      if (isset($item['target_id'])) {
+      // Handle bundle['target_id']
+      // Exclude image field to keep metadata (alt / title)
+      if (isset($item['target_id']) && !isset($item['alt']) && !isset($item['title'])) {
         $value = $item['target_id'];
       }
       elseif (is_scalar($item) || (count($item) != 1 && !isset($item['width']) && !isset($item['pid']))) {
@@ -120,11 +122,6 @@ class ReinstallSourceBase extends SourcePluginBase implements ContainerFactoryPl
       elseif (isset($item['value'])) {
         $value = $item['value'];
       }
-      // Handle bundle['target_id']
-      // Exclude image field to keep metadata (alt / title)
-      elseif (isset($item['target_id']) && !isset($item['alt']) && !isset($item['title'])) {
-        $value = $item['target_id'];
-      }
       elseif (isset($item['pid'])) {
         $value = $item['alias'];
       }
@@ -166,7 +163,9 @@ class ReinstallSourceBase extends SourcePluginBase implements ContainerFactoryPl
   protected function initialParse(array $configuration, string $key = NULL) {
     $this->sstEntityType = $type = $configuration['type'];
     $bundle = $configuration['bundle'];
-    $baseFilePath = "${type}/${bundle}.yml";
+
+    $baseFilePath = $this->configuration['file'] ?? "${type}/${bundle}.yml";
+
     $importPath = $configuration['importPath'] ?? NULL;
     $filePath = "$importPath/$baseFilePath";
     $realPath = realpath($filePath);