import { useAction } from 'Dashboard'
import { useRef, useEffect } from 'react'
const MyAwesomeComponent = props => {
const ICP = useRef()
useEffect(() => {
const getInstance = useAction('com.naviga.icp:getInstance')
const Instance = getInstance()
const handler = new Instance()
ICP.current = handler.getImageProvider('name-of-image-provider') // i.e. "imengine-provider" from example config
}, [])
/**
Now you can use ICP all around your plugin.
In order to build an image src call:
ICP.current.getImageSrc(ICP_FUNCTION, IMAGE_PARAMS)
const imgSrc = ICP.current.getImageSrc('crop', {
identifier: "123e4567-e89b-12d3-a456-426655440000",
width: 400,
height: 300,
x: 20,
y: 45
})
imgSrc === https://domain/imengine/image.php?uuid=123e4567-e89b-12d3-a456-426655440000&type=preview&function=cropresize&width=400&height=300&x=20&y=45&crop_w=400&crop_h=300&q=80
*/
}
import { Component } from 'react'
import { useAction } from 'Dashboard'
class MyAwesomeComponent extends Component {
constructor(props) {
super(props)
this.ICP = null
}
componentDidMount() {
const getInstance = useAction('com.naviga.content-agent:getInstance')
const Instance = getInstance()
const handler = new Instance()
this.ICP = handler.getImageProvider('name-of-image-provider') // i.e. "imengine-provider" from example config
}
/**
Now you can use ICP all around your plugin.
In order to build an image src call:
this.ICP.getImageSrc(ICP_FUNCTION, IMAGE_PARAMS)
const imgSrc = this.ICP.getImageSrc('crop', {
identifier: "123e4567-e89b-12d3-a456-426655440000",
width: 400,
height: 300,
x: 20,
y: 45
})
imgSrc === https://domain/imengine/image.php?uuid=123e4567-e89b-12d3-a456-426655440000&type=preview&function=cropresize&width=400&height=300&x=20&y=45&crop_w=400&crop_h=300&q=80
*/
}