bolt / bolt/ImportWXR

Importing into video and image fields doesn't work

Open
#13 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
14
Forks
5
PR merge metrics
No merged PRs in 30d

Description

(Example based on export from PivotX, but the same problem is present for people exporting Wordpress content.)

Having entries with two extrafields in PivotX:
1. Youtube - containing the URL to an Youtube video
2. Pic - containg the filename of an image

To import these two extra fields into the default entry content type add the following two lines to the Post mapping of the default importwxr.bolt.yml / config.yml.dist.

```
pivx_extrafield_pic: image
pivx_extrafield_youtube: video
```

This seems to work when you look at the preview/dryrun, but after running the import the video and image fields are empty. The problem is that these field types stores the actual value under keys ('url' and 'file'). So basically the fix is check for these field types in the importer and make sure that the values are stored on the keys. After line 174 in bolt/extensions/vendor/bolt/importwxr/Extension.php add:

```
case "video":
$value = serialize(array('url' => $value));
break;
case "image":
$value = serialize(array('file' => $value));
break;
```

This works great if you use the default entry content type in Bolt. However, if you add a field yourself named for example Youtube with type "video" and try to import the same PivotX Youtube extra field into that Bolt fields it will fail because the function importPost doesn't load the field type, only the field name ... @bobdenotter, what do you think?

PS! Excerpt from entries.xml that contains these two extrafields:

```

pivx_extrafield_pic

_pivx_extrafield_pic

pivx_extrafield_youtube

_pivx_extrafield_youtube

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in bolt/extensions/vendor/bolt/importwxr/Extension.php, around line 174 and the importPost function. Trace how mapped fields are loaded and how video and image values are stored, including custom fields whose types must be resolved. Done means imported video and image fields retain their URL and filename after the import, not only in preview or dry-run.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.