Endpoint to render custom assets
Hi,
I have a question about using endpoints to render assets (mainly images).
We have a local dev setup to use Grunt to compile our custom JS & CSS, mainly because it allows us to write modular JavaScript code and compile/bundle it in one file to be uploaded to studio. This approach works fine with JavaScript no problems. For CSS generation however, we use modular less files to avoid having to write too much vanilla CSS. The only problem with this is when the CSS needs to reference background images that are also custom assets within our community.
We initially tried something like this in our less files:
// Get less to ignore url when compiling background: ~'url(${asset.get("/html/assets/asset_name.gif")})'
This works with following limitations:
- Hard to do local testing
- You can only copy paste the CSS inside "Skin CSS" field of the community admin
I thought I would create a custom endpoint that would take path of the asset as url parameter and render the asset using asset & http.client freemarker objects. If I can get this endpoint to render the image content, I can then just reference the URL to this endpoint inside the less file and upload & include the generated CSS file in the head tag for all pages saving some effort in the process. Just wondering if it's possible to do since I can't seem to set a content type of image/gif or image/jpeg inside an endpoint.
Any help/suggestions/work-arounds will be much appreciated.
Kind Regards,
Hiral