7

I Have a magento2 EE with a headless implementation. Hence I am using the rest/V1/cmsBlock/<id> to fetch the content which is added by admin (WYSIWYG).

Problem:

I see the output like :

<response>
    <id>2</id>
    <identifier>pirates</identifier>
    <title>Pirates are Back!</title>
    <content>
        <h2><img src="{{media url="wysiwyg/the-Pirates-of-the-Caribbean--172-Jack-Sparrow.jpg"}}" alt="Pirates are Back" width="387" height="259" /></h2>
    </content>
    <creation_time>2017-01-09 16:03:20</creation_time>
    <update_time>2017-01-09 16:07:12</update_time>
    <active>true</active>
</response>

Now my front-end does not understand

{{media url="wysiwyg/the-Pirates-of-the-Caribbean-Pop-172-Jack-Sparrow.jpg"}}

So now, how do I get the actual URL of the image instead of the variable? As a part of the XML response itself without overriding the API.

1 Answer 1

0

You could build a data post-processor in your headless client that can resolve directives. It may be difficult to support all possible types, but depending on what you need to support, it might be pretty simple. For this example, you could use the /rest/V1/store/storeConfigs endpoint to retrieve the media_base_url. Then you can resolve the full media URL and replace it into the CMS content.

REST doc for store/storeConfigs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.