You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use the Cloudimage Cloud plugin, you will need a Cloudimage token to deliver your images over CDN. Don't worry, it only takes seconds to get one by registering here. Once your token is created, you can configure it as described below.
Installation
To start using this plugin simply add it to your project with the package manager of your choice.
yarn add react-native-cloudimage-cloud
OR
npm install react-native-cloudimage-cloud
Setup
Before you can use any of the components you should configure the plugin with setPluginConfig. See next table for an exhaustive list of configuration object.
// App.tsx
setPluginConfig(config);
export default function App() {
//
}
Configuration object
Property
Type & Default
Description
token
string : ''
Required. Part of the resource URL. Your Cloudimage customer token. Subscribe for a Cloudimage account to get one. The subscription takes less than a minute.
placeholderBackground
string : '#f4f4f4'
Placeholder coloured background while the image is loading. Can be set to a valid URL in order do display some other resource (image, git, etc.) to display while main resource is loading.
domain
string : 'cloudimage.io'
Part of the resource URL. Change this if you use a custom CNAME for your Cloudimage integration.
baseUrl
string : '/'
Part of the resource URL. Your image folder at origin; this alows to shorten your origin image URLs.
limitFactor
number : 100
Rounds up the size of the image to the nearest limitFactor value (for an image with width 358px and limitFactor equal to 100, the plugin will round up to 400px).
doNotReplaceURL
boolean : false
If set to true, the plugin will only add query parameters to the provided image source URL. As a result, resource URL will look like this: src?operations&filters&watermarks.
devicePixelRatioList
number[] : [1, 1.5, 2]
List of supported device pixel ratios. If there is no need to support retina devices, you should set empty array. Only positive numbers limited to 5 are supported.
lazyLoading
boolean : true
If set to true plugin will lazy load requested resources.
lazyInterval
number : 1000
Interval in milliseconds used to check users viewport. Lower values means more frequent checks.
lazyThreshold
number : 50
Threshold between users viewport and resource. Higher values means that resource will load earlier.
Once that's done you can start using plugin components in your application.
Disallows image upscaling when resizing with the width or height operations. When resizing, the image can be either scaled down or up depending on the original and target dimensions.
rotate
number
Rotates the image by a specified angle, counterclockwise.
trim
number
Removes any single-color padding around the image if present. The parameter does not specify the amount of border or frame to trim but rather how aggressive the trim algorithm should be. A bigger value of the parameter (e.g. 25) might trim part of the image. Typical values are between 0 and 10.
removeBackgound
boolean
Background removal automatically detects the foreground object and isolates it by removing the background of an image using advanced AI technology. Please keep in mind that the background removal operation is asynchronous which means that the first request will return the original image.
margin
number
Defines a minimum margin when fitting the image in a new canvas. Used with function: 'fit'.
upscaleImage
boolean
Allows upscaling smaller images to the desired dimensions (will result in inferior image resolution). Used with function: 'fit'.
blurBackground
boolean
Sets blurred image background. Used with function: 'fit'.
blurBackgroundValue
number
Applies Gaussian blur to the background image. Used with function: 'fit' and blurBackground: true.
backgroundOpacity
number
Specifies background image opacity. Used with function: 'fit' and blurBackground: true.
backgroundTintColor
number
Defines a color to tint the background image. Used with function: 'fit' and blurBackground: true.
backgroundColor
string
Color in hexadecimal format or basic color f.e. red. Used with function: 'fit' and blurBackground: true.
devicePixelRatio
number
Allows you to deliver the proper image dimensions according to a defined device pixel ratio. This operation can help with conversion between device-independent pixels and CSS (reference) pixels.
backgroundGravity
string
Defines the positioning of the background image within its container. Possible values: 'north', 'northwest', 'northeast', 'west', 'centre', 'center', 'east', 'southwest', 'south', 'southeast', 'trim'. Used with function: 'fit' and blurBackground: true.
Sets the position of the image in the fit box. Possible values: 'north', 'northwest', 'northeast', 'west', 'centre', 'center', 'east', 'southwest', 'south', 'southeast', 'trim', 'auto', 'face', 'trim', 'smart'orOperationFocalPointInterface. Used with function: 'fit'.
You can use plain string instead of object as well. See Cloudimage documentation for more examples.
Property
Type
Description
addWatermark
boolean
Set to 'true' to enable watremarking.
opacity
number
Defines watermark opacity.
url
string
The URL of the watermark image. Can be URL-encoded. Required for external watermark type.
text
string
Any text that you want to be displayed. Required for text watermark type.
font
string
Font family to be used for text watermark.
textColor
string
Color in hexadecimal format or basic color f.e. red.
watermarkGravity
string
Defines the position to "anchor" the watermark to. Possible values: 'north', 'northwest', 'northeast', 'south', 'southwest', 'southeast', 'east', 'west', 'absolute', 'realtive', 'center'.