Page 1 of 1

Rendering image by passing image ID to REST service

Posted: Fri Jun 17, 2016 6:05 am
by hatchjk
In our document type, images are referenced by the image's asset ID in our asset management system:

<img src="1234567" alt="test image' />

In other content preview environments, images are previewed by passing the asset ID to a REST service:

https://publish.our_organization.org/content_automation/ws/v1/getImage?mediaId=1234567

... which returns an image rendition, usually in .png format.

If I actually edit the @src on the image to:

<img src="https://publish.our_organization.org/content_automation/ws/v1/getImage?mediaId=1234567"

... I get the proper rendition and preview in Author. However, I'd prefer to not alter the @src in the content, but rather somehow implement some sort of image element display handler to iteratively pass each image asset ID in the open document to the service and allow service returns to drive image previews.

Could such an action or extension be implemented in Oxygen for previewing images in custom Document Type's Author mode? If it's not possible to do this without actually manipulating xml fragments in the open document, our documents are already being routed through transformation on save or re-upload, and functionality could be added to that transformation to strip the service call URL

Any advice?

Re: Rendering image by passing image ID to REST service

Posted: Fri Jun 17, 2016 10:26 am
by mihaela
Hi,

What you can do is to modify the image URL from CSS.
The following CSS sample changes the URL of all img elements by adding the "https://publish.our_organization.org/content_automation/ws/v1/getImage?mediaId=" prefix to the "src" attribute value:

Code: Select all


img {
content: url(oxy_concat("https://publish.our_organization.org/content_automation/ws/v1/getImage?mediaId=", attr(src)));
}

Best regards,
Mihaela