Update image paths
This commit is contained in:
parent
48ff8401e9
commit
90ec6af8f9
8 changed files with 21 additions and 21 deletions
2
04.txt
2
04.txt
|
@ -14,7 +14,7 @@ source:
|
||||||
unique_id: 1
|
unique_id: 1
|
||||||
name: 'Michele Metts'
|
name: 'Michele Metts'
|
||||||
profile: '<a href="https://www.drupal.org/u/freescholar" title="Michele on Drupal.org">freescholar</a> on Drupal.org'
|
profile: '<a href="https://www.drupal.org/u/freescholar" title="Michele on Drupal.org">freescholar</a> on Drupal.org'
|
||||||
photo_url: 'https://agaric.coop/sites/default/files/2018-12/micky-cropped.jpg'
|
photo_url: 'https://udrupal.com/photos/freescholar.jpg'
|
||||||
photo_description: 'Photo of Michele Metts'
|
photo_description: 'Photo of Michele Metts'
|
||||||
photo_width: '587'
|
photo_width: '587'
|
||||||
photo_height: '657'
|
photo_height: '657'
|
||||||
|
|
6
05.txt
6
05.txt
|
@ -91,18 +91,18 @@ Let’s see part of the _source_ definition:
|
||||||
```yaml
|
```yaml
|
||||||
source:
|
source:
|
||||||
constants:
|
constants:
|
||||||
BASE_URL: "https://agaric.coop"
|
BASE_URL: "https://udrupal.com"
|
||||||
PHOTO_DESCRIPTION_PREFIX: "Photo of"
|
PHOTO_DESCRIPTION_PREFIX: "Photo of"
|
||||||
plugin: embedded_data
|
plugin: embedded_data
|
||||||
data_rows:
|
data_rows:
|
||||||
- unique_id: 1
|
- unique_id: 1
|
||||||
name: "Michele Metts"
|
name: "Michele Metts"
|
||||||
photo_url: "sites/default/files/2018-12/micky-cropped.jpg"
|
photo_url: "photos/freescholar.jpg"
|
||||||
photo_width: "587"
|
photo_width: "587"
|
||||||
photo_height: "657"
|
photo_height: "657"
|
||||||
```
|
```
|
||||||
|
|
||||||
Only one record is presented to keep snippet short, but more exist. In addition to having a unique identifier, each record includes a name, a short profile, and details about the image. Note that this time, the `photo_url` does not provide an absolute URL. Instead, it is a relative path from the domain hosting the images. In this example, the domain is `https://agaric.coop` so that value is stored in the BASE_URL constant which is later used to assemble a valid absolute URL to the image. Also, there is no photo description, but one can be created by concatenating some strings. The PHOTO_DESCRIPTION_PREFIX constant stores the prefix to add to the name to create a photo description.
|
Only one record is presented to keep snippet short, but more exist. In addition to having a unique identifier, each record includes a name, a short profile, and details about the image. Note that this time, the `photo_url` does not provide an absolute URL. Instead, it is a relative path from the domain hosting the images. In this example, the domain is `https://udrupal.com` so that value is stored in the BASE_URL constant which is later used to assemble a valid absolute URL to the image. Also, there is no photo description, but one can be created by concatenating some strings. The PHOTO_DESCRIPTION_PREFIX constant stores the prefix to add to the name to create a photo description.
|
||||||
|
|
||||||
Now, let’s see the _process_ definition:
|
Now, let’s see the _process_ definition:
|
||||||
|
|
||||||
|
|
10
07.txt
10
07.txt
|
@ -20,18 +20,18 @@ The _source_ of a migration is independent of its _destination_. The following c
|
||||||
```yaml
|
```yaml
|
||||||
source:
|
source:
|
||||||
constants:
|
constants:
|
||||||
SOURCE_DOMAIN: "https://agaric.coop"
|
SOURCE_DOMAIN: "https://udrupal.com"
|
||||||
DRUPAL_FILE_DIRECTORY: "public://portrait/"
|
DRUPAL_FILE_DIRECTORY: "public://portrait/"
|
||||||
plugin: embedded_data
|
plugin: embedded_data
|
||||||
data_rows:
|
data_rows:
|
||||||
- photo_id: "P01"
|
- photo_id: "P01"
|
||||||
photo_url: "sites/default/files/2018-12/micky-cropped.jpg"
|
photo_url: "photos/freescholar.jpg"
|
||||||
- photo_id: "P02"
|
- photo_id: "P02"
|
||||||
photo_url: ""
|
photo_url: ""
|
||||||
- photo_id: "P03"
|
- photo_id: "P03"
|
||||||
photo_url: "sites/default/files/pictures/picture-94-1480090110.jpg"
|
photo_url: "photos/gnuget.jpg"
|
||||||
- photo_id: "P04"
|
- photo_id: "P04"
|
||||||
photo_url: "sites/default/files/2019-01/clayton-profile-medium.jpeg"
|
photo_url: "photos/cedewey.jpg"
|
||||||
ids:
|
ids:
|
||||||
photo_id:
|
photo_id:
|
||||||
type: string
|
type: string
|
||||||
|
@ -103,7 +103,7 @@ psf_source_image_path:
|
||||||
- plugin: urlencode
|
- plugin: urlencode
|
||||||
```
|
```
|
||||||
|
|
||||||
The end result of this operation will be something like `https://agaric.coop/sites/default/files/2018-12/micky-cropped.jpg`. Note that the `concat` and `url_encode` plugins are used just like in the previous step. A subtle difference is that a `delimiter` is specifying in the concatenation step. This is because, contrary to the `DRUPAL_FILE_DIRECTORY` constant, the `SOURCE_DOMAIN` constant does not end with a _slash_ (**/**). This was done intentionally to highlight two things. First, it is important to understand your source data. Second, you can transform it as needed by using various process plugins.
|
The end result of this operation will be something like `https://udrupal.com/photos/freescholar.jpg`. Note that the `concat` and `url_encode` plugins are used just like in the previous step. A subtle difference is that a `delimiter` is specifying in the concatenation step. This is because, contrary to the `DRUPAL_FILE_DIRECTORY` constant, the `SOURCE_DOMAIN` constant does not end with a _slash_ (**/**). This was done intentionally to highlight two things. First, it is important to understand your source data. Second, you can transform it as needed by using various process plugins.
|
||||||
|
|
||||||
## Copying the image file to Drupal
|
## Copying the image file to Drupal
|
||||||
|
|
||||||
|
|
6
15.txt
6
15.txt
|
@ -98,9 +98,9 @@ The final example will show a slight variation of the previous configuration. Th
|
||||||
|
|
||||||
| | |
|
| | |
|
||||||
|-|-|-|
|
|-|-|-|
|
||||||
| P01 | https://agaric.coop/sites/default/files/pictures/picture-15-1421176712.jpg |
|
| P01 | https://udrupal.com/photos/freescholar.jpg |
|
||||||
| P02 | https://agaric.coop/sites/default/files/pictures/picture-3-1421176784.jpg |
|
| P02 | https://udrupal.com/photos/mlncn.jpg |
|
||||||
| P03 | https://agaric.coop/sites/default/files/pictures/picture-2-1421176752.jpg |
|
| P03 | https://udrupal.com/photos/sfreudenberg.jpg |
|
||||||
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|
4
16.txt
4
16.txt
|
@ -41,7 +41,7 @@ This migration will reuse the same configuration from the [introduction to parag
|
||||||
"udm_photos": [
|
"udm_photos": [
|
||||||
{
|
{
|
||||||
"photo_id": "P01",
|
"photo_id": "P01",
|
||||||
"photo_url": "https://agaric.coop/sites/default/files/pictures/picture-15-1421176712.jpg",
|
"photo_url": "https://udrupal.com/photos/freescholar.jpg",
|
||||||
"photo_dimensions": [240, 351]
|
"photo_dimensions": [240, 351]
|
||||||
},
|
},
|
||||||
{...},
|
{...},
|
||||||
|
@ -207,7 +207,7 @@ Let's consider an example where the records to migrate have *more data than need
|
||||||
"udm_photos": [
|
"udm_photos": [
|
||||||
{
|
{
|
||||||
"photo_id": "P01",
|
"photo_id": "P01",
|
||||||
"photo_url": "https://agaric.coop/sites/default/files/pictures/picture-15-1421176712.jpg",
|
"photo_url": "https://udrupal.com/photos/freescholar.jpg",
|
||||||
"photo_dimensions": [240, 351]
|
"photo_dimensions": [240, 351]
|
||||||
},
|
},
|
||||||
{...},
|
{...},
|
||||||
|
|
4
17.txt
4
17.txt
|
@ -44,7 +44,7 @@ This migration will reuse the same configuration from the [introduction to parag
|
||||||
</udm_book_paragraph>
|
</udm_book_paragraph>
|
||||||
<udm_photos>
|
<udm_photos>
|
||||||
<photo_id>P01</photo_id>
|
<photo_id>P01</photo_id>
|
||||||
<photo_url>https://agaric.coop/sites/default/files/pictures/picture-15-1421176712.jpg</photo_url>
|
<photo_url>https://udrupal.com/photos/freescholar.jpg</photo_url>
|
||||||
<photo_dimensions>
|
<photo_dimensions>
|
||||||
<width>240</width>
|
<width>240</width>
|
||||||
<height>351</height>
|
<height>351</height>
|
||||||
|
@ -229,7 +229,7 @@ Let's consider an example where the elements to migrate have *more data than nee
|
||||||
<data>
|
<data>
|
||||||
<udm_photos>
|
<udm_photos>
|
||||||
<photo_id>P01</photo_id>
|
<photo_id>P01</photo_id>
|
||||||
<photo_url>https://agaric.coop/sites/default/files/pictures/picture-15-1421176712.jpg</photo_url>
|
<photo_url>https://udrupal.com/photos/freescholar.jpg</photo_url>
|
||||||
<photo_dimensions>
|
<photo_dimensions>
|
||||||
<width>240</width>
|
<width>240</width>
|
||||||
<height>351</height>
|
<height>351</height>
|
||||||
|
|
6
20.txt
6
20.txt
|
@ -78,9 +78,9 @@ destination:
|
||||||
Now let's consider an example of a spreadsheet file that does not have a header row. This example is for the *image* migration and uses a Microsoft Excel file. The following snippets shows the `UD Example Sheet` worksheet and the configuration of the *source* plugin:
|
Now let's consider an example of a spreadsheet file that does not have a header row. This example is for the *image* migration and uses a Microsoft Excel file. The following snippets shows the `UD Example Sheet` worksheet and the configuration of the *source* plugin:
|
||||||
|
|
||||||
```
|
```
|
||||||
P01, https://agaric.coop/sites/default/files/pictures/picture-15-1421176712.jpg
|
P01, https://udrupal.com/photos/freescholar.jpg
|
||||||
P02, https://agaric.coop/sites/default/files/pictures/picture-3-1421176784.jpg
|
P02, https://udrupal.com/photos/mlncn.jpg
|
||||||
P03, https://agaric.coop/sites/default/files/pictures/picture-2-1421176752.jpg
|
P03, https://udrupal.com/photos/sfreudenberg.jpg
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|
4
28.txt
4
28.txt
|
@ -42,7 +42,7 @@ $ drush migrate:import udm_csv_source_image --migrate-debug --limit=1
|
||||||
└──────────────────────────────────────────────────────────────────────────────┘
|
└──────────────────────────────────────────────────────────────────────────────┘
|
||||||
array (10) [
|
array (10) [
|
||||||
'photo_id' => string (3) "P01"
|
'photo_id' => string (3) "P01"
|
||||||
'photo_url' => string (74) "https://agaric.coop/sites/default/files/pictures/picture-15-1421176712.jpg"
|
'photo_url' => string (74) "https://udrupal.com/photos/freescholar.jpg"
|
||||||
'path' => string (76) "modules/custom/ud_migrations/ud_migrations_csv_source/sources/udm_photos.csv"
|
'path' => string (76) "modules/custom/ud_migrations/ud_migrations_csv_source/sources/udm_photos.csv"
|
||||||
'ids' => array (1) [
|
'ids' => array (1) [
|
||||||
string (8) "photo_id"
|
string (8) "photo_id"
|
||||||
|
@ -69,7 +69,7 @@ array (10) [
|
||||||
array (4) [
|
array (4) [
|
||||||
'psf_destination_filename' => string (25) "picture-15-1421176712.jpg"
|
'psf_destination_filename' => string (25) "picture-15-1421176712.jpg"
|
||||||
'psf_destination_full_path' => string (25) "picture-15-1421176712.jpg"
|
'psf_destination_full_path' => string (25) "picture-15-1421176712.jpg"
|
||||||
'psf_source_image_path' => string (74) "https://agaric.coop/sites/default/files/pictures/picture-15-1421176712.jpg"
|
'psf_source_image_path' => string (74) "https://udrupal.com/photos/freescholar.jpg"
|
||||||
'uri' => string (29) "./picture-15-1421176712_6.jpg"
|
'uri' => string (29) "./picture-15-1421176712_6.jpg"
|
||||||
]
|
]
|
||||||
┌──────────────────────────────────────────────────────────────────────────────┐
|
┌──────────────────────────────────────────────────────────────────────────────┐
|
||||||
|
|
Loading…
Reference in a new issue