Grouping and Structuring Media Items
SAP Commerce enables a few means of grouping and structuring media items:
-
Assigning a Media Format to media items to keep track of the format of the media
-
Assigning multiple media to a Media Container to group the media logically
-
Assigning multiple media formats to a Media Context to define a replacement list for media formats in a given context
Keeping Track of Formats Through Media Formats
Each media item can have one Media Format assigned. A Media Format is simply a tag assigned to a media item, called a logical label. It does not invoke any functionality such as automatic conversion. For example, if a media item has a “50x50px” media format assigned to it, it doesn't mean the file is necessarily 50 by 50 pixels in size, nor has been converted or scaled to 50x50 pixels automatically. It only means that the media has the “50x50px” label assigned to it. You have to provide any conversion or re-scaling functionality explicitly by using a media asset management system.
Grouping Media Using Media Containers
Media items in SAP Commerce can be assigned to individual Media Containers for logical grouping. One single media item can only be assigned to one Media Container, which holds all media items that are different formats of one certain media item. For example, a Media Container can hold all media items of a certain product, no matter what file type or measurement of the actual files. In essence, a Media Container is a rule of which media items to use for which media format. A media item can only be assigned to a Media Container if the media item has a media format set.
A Media Container is intended primarily for images. Generally, product-relevant media items of which, only one version is available at any given time such as data sheets, spare-parts lists, and manuals in PDF format are not a useful field of application for Media Containers. However, if you have product data sheets in different versions such as individual layouts for Letter and DIN A4 formats, then a Media Container may be useful.
In this example, the 30125_medium media item is in Picture Format - picture - 7, the 30125_thumbnail media item is in Thumbnail Format - thumbnail - 8, and the 30125 media item is in Original Media Format - original - 6.
This graphic shows the basic structure. The media 30125_thumbnail, and 30125_medium are different versions (that is, media formats) of one single media: 30125. Each of the media has a media format. The media container reflects the fact that these media are related by holding the media and their respective media format. The media container can look up which of its media is available in a given media format. That way, it’s possible to get a media in a certain media format using the media container.
Using the media container, you do not have to explicitly retrieve the media in a certain media format. You can use the MediaService method, getMediaByFormat(MediaModel, MediaFormatModel) to get the media representation in a given format. The media service will look for the media container and return media in the specified format, if it is available. This is fully transparent and you do not have to use media container explicitly. See the example:
final MediaModel mediaModel = ... final MediaFormatModel formatModel = ... final MediaModel mediaInRequiredFormat = mediaService.getMediaByFormat(mediaModel, formatModel);
In the example above, if the media item, 30125 were asked to return its representation in the Picture Format - picture - 7, the media container would return the 30125_medium media item.
For more information, see Handle Media Using the MediaContainer
Grouping Media Formats Using Media Contexts
Media Contexts are to Media Formats what Media Containers are for Media items. It's a rule on which media formats to use instead of others in any given context. In essence, a Media Context tells the user, "if you run across media items in this media format, replace them with the media items in the other media format".
A Media Context therefore defines a mapping of media formats. One entry holds the media formats to replace, and the other entry holds the media format to use as a replacement.
Media Context high-res in the screenshot defines these replacement rules:
|
Source Media Format |
To be Replaced by Media Format |
|---|---|
|
Original Media Format - original - 6 |
Original Media Format - original - 6 |
|
Picture Format - picture - 7 |
Original Media Format - original - 6 |
|
Thumbnail Format - thumbnail - 8 |
Original Media Format - original - 6 |
This assures that for all images, the media in the Original Media Format - original - 6 media format is selected.
The following diagram shows the replacement table of the high-res Media Context and of a low-res Media Context in a graphical way: