Integration
The colormass Exports feature can be used through a web component called cm-material-download
. This enables you to directly use the download functionality without having to download or upload these assets that are defined in the previous page (Generating Exports ).
Steps
1. Add an Import in the site's header
In order to be able to use the exports component you need to add an import into the <header>
HTML element, like so:
This only needs to be done once.
2. Add a button
Now add a download button to your page. This must be an a
tag. You can add arbitrary content, CSS classes and attributes to make this appear like any other button on your page. Your existing CSS rules will continue to apply. The href
attribute can be either omitted or set to an arbitrary value.
3. Wrap the link
Now wrap the a
tag in a cm-material-download
tag, providing the attributes described below. The link's href
tag will be set automatically. If the required export cannot be found, the CSS class disabled
will be set on the link.
You need to define the following attributes:
organization-id
: This is a fixedUUID
for your account (please ask your contact person if you are not sure).article-id
: This is the article IDstring
of the material. Since these are added on the platform manually, please ask the colormass staff if the corresponding range has the correct article IDs added before integrating them.type
: This is the type of the download. It has the following options:pbr
,tile
,thumbnail
.file-type
: The desired file extension:jpg
ortiff
.resolution (PBR)
:low
(72 DPI) orhigh
(Original DPI)resolution
: The desired resolution, one oflow
(1000x1000px),medium
(2000x2000px) orhigh
(original size). Must behigh
unless the file type isjpg
. Defaults tohigh
.dimensions
: One of7x7in
,9x9in
,16x16in
,10x10cm
,20x20cm
,30x30cm
. Only provide if type isthumbnail
. Defaults to7x7in
.
If you are not sure what these types above mean, please check the previous Generating Exports page.
Styling
This component doesn't add any styling rules. The wrapped a
tag can be styled freely. In most cases, it should automatically pick up any existing styling rules on the page, so that no extra steps are necessary. If you do want to customize the appearance of the link, you can simply add CSS classes or inline styles. See the following example:
Example
If it's needed you can also set the attributes programmatically like you would with any HTML attribute. Just as an example using in pure Javascript:
The above example is just an example if you use frameworks or libraries this example would probably look different.
The HTML component lets you define any values, so you have to make sure that:
The output you are requesting is available on the colormass platform
The article ID is added to the material on the platform and uniquely identifies a material
For example, if you request the download of Article ID 9999 with the following attributes:
The download will not start because it doesn't have a 9in x 9in output. The a
tag will additionally have the CSS class disabled
, which you can use to provide feedback to the user.
As an alternative to the cm-material-download
web component, you can also generate download links directly using the colormass GraphQL API.
Last updated