Video import

As for every video, a preview image is needed as well, the video import, in general, is an extension of the image import.

Roles

For both images and videos, Magento provides so-called roles that can be used to define where the image or has to be rendered.

If necessary, the default roles can dynamically be extended. W henever a new role has been added, Pacemaker has support for it by adding new columns that match the role name.

By default, the following roles are available and can be used to define which role an imported image or video should have.

Role Description

base

  • The base image is the primary image on the product detail page.

  • Image zoom is activated if you upload an image that is a larger image than the image container.

  • Depending on the zoom level that you want to achieve, the base image should be two or three times the container’s size.

  • Example sizes

    • without Zoom: 470 x 470 pixel

    • with Zoom: 1100 x 1100 pixel

small

The small image is used for the product images in listings on category and search results pages and displays the product images needed for sections such as for Up-sells, Cross-sells, and the New Products List.

  • Example size: 470 x 470 pixel

thumbnail

Thumbnail images appear in the thumbnail gallery, shopping cart, and in some blocks such as Related Items.

  • Example size: 50 x 50 pixels

swatch

A swatch can be used to illustrate the color, pattern, or texture. Example size: 50 x 50 pixels

  • Example size: 50 x 50 pixels

File Structure

The file structure for images and videos can be dynamically and depends on the roles an image has to be related.

For example, when only one image with the role base should be imported, it’s enough to have the columns base_image. The columns base_image_label and base_image_position are optional.

For each additional role, an image has to be related to, the additional columns are necessary, either it is the same image or not.

Column Name Type Example Description

<role>_image

varchar

/m/b/mb01-blue-0.jpg

The relative path to the image, starting with a slash (/).

<role>_image_label

varchar

This is my image.

The image label used as alt text.

<role>_image_position

integer

1

The position the image should be rendered in the admin backend and frontend.

additional_images

varchar

/m/b/mb01-blue-0.jpg,/m/b/mb01-blue-1.jpg,/m/b/mb01-blue-2.jpg

This column must contain a comma (,) separated list of relative paths to images.

additional_image_labels

varchar

This is my image 1,, This is my image 2

This column must contain a comma (,) separated list of alt texts for the images in the column additional_attributes whereas it must exactly have the same number of elements as additional images have been specified.

additional_image_positions

integer

1,3,2

This column must contain a comma (,) separated list positions for the images in the column additional_attributes whereas it must exactly have the same number of elements as additional images have been specified.

<role>_video

text

The URL to the video should be loaded, by default, only videos from YouTube (needs an API key) or Vimeo are supported.

<role>_video_title

varchar(255)

Pacemaker Product Import

The title will be displayed on top of the video on the product detail page when the user hovers over the video.

<role>_video_description

text

This video shows a simple Import Framework product import in a Magento 2 shop instance.

A description of the video which will be visible in the admin backend only.

<role>_video_provider

varchar(32)

YouTube

The name of the video provider, is either YouTube or Vimeo .

<role>_video_metadata

text

Pacemaker

Additional metadata for the video that will be visible in the Admin backend only.

additional_videos

varchar

This column must contain a comma (,) separated list of URLs to additional videos that should be loaded.

additional_video_titles

varchar(255)

Pacemaker product import, A second video about product import

This column must contain a comma (,) separated list of titles for the videos in the column additional_videos whereas it must exactly have the same number of elements as additional videos have been specified.

The title will be displayed above the video on the product detail page if a user hovers over the video.

additional_video_descriptions

text

Pacemaker product import,A second video about product import

This column must contain a comma (,) separated list of descriptions for the videos in the column additional_videos whereas it must exactly have the same number of elements as additional videos have been specified.

The descriptions will be visible in the admin backend only.

additional_video_providers

varchar(32)

YouTube, Vimeo

This column must contain a comma (,) separated list of provides for the videos in the column additional_videos whereas it MUST exactly have the same number of elements as additional videos have been specified. One of YouTube or Vimeo can be used.

additional_video_metadata

text

YouTube, Vimeo

This column must contain a comma (,) separated list of metadata for the videos in the column additional_videos whereas it must exactly have the same number of elements as additional videos have been specified.

The metadata will be visible in the admin backend only.

hide_from_product_page

varchar

/m/b/mb01-blue-0.jpg,/m/b/mb01-blue-2.jpg

Contains a comma (,) separated list of the relative image paths that should not be rendered on the product detail page, whereas it doesn’t matter if it is an image with a role or one of the additional images

disabled_images

varchar

/m/b/mb01-blue-0.jpg,/m/b/mb01-blue-2.jpg

Contains a comma (,) separated list of the relative image paths that should not be rendered anywhere, whereas it doesn’t matter if it is an image with a role or one of the additional images

If you currently want to import videos to the additional_videos column (which is almost always the case if videos are not base, small or thumbnail), the corresponding preview images at the additional_images column must be placed first, because the index of the images is used to assign the videos in the additional_videos column.

Here is a small example:

Column additional_images /a/z/AzXrs1c92RY.jpg,/m/b/mb03-black-0_alt1.jpg

Column additional_videos https://youtu.be/AzXrs1c92R

During the import process, when the additional_videos column is unpacked, the value is assigned based on its index, i.e., the video with the URL https://youtu.be/AzXrs1c92RY has index 0 and is thus assigned to the image with index 0 in the addtional_images column, i.e. the image /a/z/AzXrs1c92RY.jpg.

If the pictures in the column additional_images would now be reversed, i.e. /m/b/mb03-black-0_alt1.jpg,/a/z/AzXrs1c92RY.jpg then the video would be wrongly assigned to the image /m/b/mb03-black-0_alt1.jpg.

So the preview images of the videos must be in the additional_image column first.

Otherwise, the assignment does not work.

The order in the additional_videos column must correspond to the order of the preview images.

Otherwise, the transfer will not work.

The actual order for the display in Admin backend and frontend can then be imported accordingly using the *_position columns.

Dedicated media import

Besides the possibility of importing videos, like images, with the product import itself, the Pacemaker Professional Edition (PE) comes with a command that allows a dedicated import of media files, including pictures and videos.

To give you a better idea, we have a repository with sample data that contains a CSV file that only includes the necessary columns for a dedicated media import.

To run a dedicated media import and import a video for the product with the SKU 24-MB01, it is necessary to configure the YouTube API first, before the following c ommand can be invoked.

cd <magento-install-dir> \
  && rm var/pacemaker/import/*.csv \
  && cp <sample-data-pro-dir>/* var/pacemaker/import \
  && vendor/bin/pacemaker import:products:media add-update \
    --clear-artefacts=false \
    --archive-artefacts=false \
    --serial=import \
    --source-dir=var/pacemaker \
    --target-dir=var/pacemaker

After refreshing the indexes, the video should be visible on the product detail page on the frontend and in the admin backend.