kontent-ai / delivery-sdk-js

Kontent Delivery SDK for Javascript
https://kontent.ai
MIT License
50 stars 34 forks source link

Add support to resolveHTML for an image #272

Closed surfinzap closed 3 years ago

surfinzap commented 4 years ago

Motivation

This is how Image is resolved in Rich-text element today:

<figure>
    <img src="">
</figure>

For our project we need to render image in the following way:

<figure>
    <img src="">
    <figcaption>caption</figcaption>
</figure>

Proposed solution

Ideally, I would able to extend resolver for an image su supply my desired HTML markup.

Domitnator commented 4 years ago

@surfinzap You have to implement the richTextResolver for that and make sure you insert the image as a component (so you might also need to create a new content model for that):

image

surfinzap commented 4 years ago

@Domitnator thanks! That's exactly how I worked around it. But from the perspective of content editor, it is an unnecessary step I have to teach them. That's why it would be better to be able to write own resolver for images.

Enngage commented 3 years ago

This feature is available in the next version of the SDK as can be demonstrated by following test (https://github.com/Kentico/kontent-delivery-sdk-js/blob/vnext/test/browser/isolated-tests/resolvers/browser-rich-text-resolver/browser-rich-resolver-html-priority.spec.ts#L29)