Migration of multi-value photos to person fields

I have to migrate from a WordPress web site to a Drupal 7 web site the place customers may add their very own photographs (like a number of person photos). I’ve a CSV file with Drupal Developer Consumer’s ID and a serialized array containing Drupal Developer filenames of uploaded photos (no, actually).

Customers have a multi-value picture area ‘field_user_pictures’.

After deserializing Drupal Developer array, drupal complains with Drupal Developer error “ltrim() expects parameter 1 to be string, array given”. (Presumably as a result of MigrateDestinationFile does not deal with arrays very properly.) Then I attempted with simply utilizing Drupal Developer first picture of Drupal Developer array, and that truly works. What does not work, nevertheless, is to get drupal to hyperlink this sole picture to Drupal Developer ‘field_user_pictures’ person area.

I’ve been making an attempt to get to one thing like this:

 class PictureMigration extends Migration  {     public perform __construct ($arguments)         {         mum or dad::__construct($arguments);          $supply = 'user_pictures.csv';          $columns = array(             1 => array('source_userid', ''),             3 => array('source_serialized', ''),         );          $source_key = array('source_userid' => array('sort' => 'int', 'not null' => TRUE),);          $this->supply = new MigrateSourceCSV($supply, $columns);         $this->vacation spot = new MigrateDestinationFile('picture', 'MigrateFileUri');         $this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationFile::getKeySchema());          $this->addFieldMapping('source_dir')->defaultValue($this->remote_dir);         $this->addFieldMapping('destination_dir')->defaultValue('public://');         $this->addFieldMapping('worth', 'source_serialized');       }    public perform prepareRow($row) {      // snipped      $row->source_serialized = $this->deserializePhotos($row->source_serialized); // returns array of filenames     }    }  public class UserMigration extends Migration {   public class __construct ($arguments) {     // snipped...       $this->addFieldMapping('field_user_pictures')->sourceMigration('PictureMigration');   } } 

Drupal Development first downside is that MigrateDestinationFile does not appear to love multi-value values; Drupal Developer second downside is that even once I solely use Drupal Developer first filename of Drupal Developer array, it nonetheless does not get linked to Drupal Developer ‘field_user_pictures’ area…

See additionally: Migration: Mix Profile2 and file migration — virtually precisely Drupal Developer similar problem, however with no legitimate reply as properly.

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Migration of multi-value photos to person fields

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.