Programmable Media

Relate assets

Last updated: Apr-18-2024

Cloudinary's related assets functionality allows users to establish relationships between assets based on specific organizational needs and criteria. By manually configuring these associations, users can create meaningful connections between assets within their library, making it easier for other users to discover and locate similar or associated assets.

You can relate any of the assets in your product environment to each other to create groupings or bundles. Here are some use cases where you might need to use related assets:

  • Relate videos and images of the same product.
  • Relate a video with its peripheral assets (transcript, poster, etc).
  • Relate an image with other images created using that image.
  • Relate images of a product with companion assets (e.g. manual, warranty, etc).
  • Relate similar product shots but from different angles or for different purposes.
  • Relate logo images and other marketing assets with a 'Brand Guidelines' PDF.
  • Relate an image with other assets that use it as an overlay.

Add related assets

The add_related_assets method allows you to indicate that a specified asset is logically related to other assets in some way. This is a bidirectional process, meaning that the asset will also be added as a related_asset to all the other assets specified. The relation is also a one to many relationship, where the asset is related to all the assets specified, but those assets are not also related to each other.

The add_related_assets method accepts the following parameters:

  • public_id or asset_id - Either the public ID of the asset, or its asset ID.
  • assets_to_relate - Relates the asset to all the other assets specified in this array of up to 10 assets, specified by either resource_type/type/public_id or by asset_id.
    For example: ["image/upload/dog","video/authenticated/cat"] or ["e12345b0efc00c0fcf","f12345a5c7c00c0f12"]

Examples

  1. Relate the image with a public ID of 'dog' to the assets with public IDs of 'image/authenticated/dog_license' and 'raw/upload/dog_subtitles.srt':

  2. Relate the asset with an asset ID of 'c789c1234bbb0e' to the assets with IDs of 'f12345a5c789c' and 'bbb0efc00c0f12':

Delete related assets

The delete_related_assets method allows you to unrelate an asset from other assets. This is a bidirectional process, meaning that the asset will also be removed as a related_asset from all the other assets specified.

The delete_related_assets method accepts the following parameters:

  • public_id or asset_id - Either the public ID of the asset, or its asset ID.
  • assets_to_unrelate - Unelates the asset from all the other assets specified in this array of assets, specified by either resource_type/type/public_id or by asset_id.
    For example: ["image/upload/dog","video/authenticated/cat"] or ["e12345b0efc00c0fcf","f12345a5c7c00c0f12"]

Examples

  1. Unrelate the asset with a public ID of 'dog' from the assets with public IDs of 'raw/upload/dog_subtitles.srt' and 'video/authenticated/animals':

  2. Unrelate the asset with a asset ID of 'c789c1234bbb0e' from the assets with IDs of 'a5c789c5c745a' and 'a1623c3b234a':

List related assets

The list of related assets is stored with the asset and is returned in the response when calling the Get details of a single resource method with the related parameter set to true.

For example, to get the details of an image with the public ID of 'red_shoe' and include the list of related assets:

✔️ Feedback sent!

Rate this page: