Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for asset renditions #58

Open
Suzii opened this issue Nov 16, 2021 · 0 comments
Open

Add support for asset renditions #58

Suzii opened this issue Nov 16, 2021 · 0 comments
Labels
hacktoberfest https://hacktoberfest.com/

Comments

@Suzii
Copy link

Suzii commented Nov 16, 2021

Motivation

New Kontent feature - Asset renditions, will be released soon (beginning of December with) and it will be available through DeliveryAPI. We should have them covered in SDKs as well.

Proposed solution

When the asset element is retrieved from Deliver, the referenced assets can now contain user-defined renditions and it is easy for the developer to apply the rendition query string to the URL of the original asset so that the customized image can be rendered in the UI.

Additional context

This is the updated Deliver contract for referenced assets of asset element:

  • New renditions property is present and it is a dictionary with a single key (for now) equal to the "default" preset codename. Presets are not a real entity for now but are part of the long-term vision of asset renditions.
    • the property will only be present for image-like objects (those which have both width & height properties set by the system)
    • when no renditions are defined for the linked asset, the empty object/dictionary is returned in the rendition property
    • if the asset is of non-image type (e.g. .pdf) the property won't be present (same as width & height in that case)
  • Ideally, to ease the adoption for the users, it would be nice to introduce support for "defaultPreset" which would automatically apply the query parameters of the rendition in preset specified by the global config.
    • Feel free to get inspired by the already implemented support in JS or .NET SDKs
  • Note, that this only applies to assets in the asset element. There is no support for renditions in inline RTE images, yet.
{
    "name": "name-of-the-uploaded-file.jpg",
    "type": "image/jpeg",
    "size": 90895,
    "description": "Description of what the asset represents.",
    "url": "https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/3e76909f-599f-4742-b472-77fd4b510e92/sources.jpg",
    "width": 1000,
    "height": 666,
    "renditions": {
      "default": {
        {
          "rendition_id": "d44a2887-74cc-4ab0-8376-ae96f3f534e5",
          "preset_id": "a6d98cd5-8b2c-4e50-99c9-15192bce2490",
          "width": 200,
          "height": 150,
          "query", "w=200&h=150&fit=clip&rect=7,23,300,200"
      }
    }
}
@Simply007 Simply007 added the hacktoberfest https://hacktoberfest.com/ label Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest https://hacktoberfest.com/
Projects
None yet
Development

No branches or pull requests

2 participants