I've been looking at the Media migration destination code and can't seem to work out how to use it.

It seems to imply that you post process imported nodes and it will look for certain elements, link images and you tube links, and do some migrate magic to make those entries into media entities.

I've been writing a migration from the phpbb forum and want to import image attachments (currently imported to a file field), you tube links (custom BBCode), and Vimeo links (Custom BBCode) to Media.

Can anyone point me in the right direction?

Thanks.

Martin...

Comments

darksnow’s picture

Found something.

The Word Press migration uses a Media Destination. Turns out it works a lot like the File Destination, which sort of makes sense.

valderama’s picture

Thanks, the Wordpress migration includes some hints on how to deal with media. However I am still not sure if its possible to fill a video media field with a youtube URL. I know that Migrate extras includes a MigrateMediaFieldHandler, but I do not know how to use it?

My scenario is pretty simple: in the migration source database I have column with the youtube URL. With some preparation this URL now looks like youtube://v/CVdI0n99FTY . This URL should be mapped to a video Media field, but I cannot make it work. It seems the file is treated like a image file, and a file copy is attempted (which does not work.)

Any hints if the MigrateMediaFieldHandler is supposed to work already?

Thanks,
walter

mikeryan’s picture

Status: Active » Fixed

With the latest Migrate/Migrate Extras 2.4-beta1, Youtube is directly supported. Basically:

$this->destination = new MigrateDestinationFile('video', 'MigrateExtrasFileYoutube');
$this->addFieldMapping('value', 'source_field_with_youtube_url');

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

finn lewis’s picture

Further to the above, it appears that we can migrate a D6 embedded YouTube field directly into a media_youtube enabled D7 file field using the file_class subfield like so:

// field_video is a file field, using the media file selector widget
// field_video_embed is the full YouTube url from the D6 embedded media field
$this->addFieldMapping('field_video', 'field_video_embed');
$this->addFieldMapping('field_video:file_class')->defaultValue('MigrateExtrasFileYoutube');