An image component in react.

Parameters:
NameTypeDescription
propsobject

Component props.

Properties
NameTypeDescription
altTextstring

The alt text for the image.

asBgboolean

Whether the image is a background image or not.

aspectRationumber

The aspect ratio of the image, as width / height. This only applies to background images.

captionJSX.Element | string

The caption for the image. This only applies if the image is a background image.

captionAttributesobject

Attributes for the image caption element.

customAttributesobject

Custom attributes for the component.

customClassesstring | Array | object

Custom classes for the component.

heightnumber

The height of the image, in px. This only applies if the image is a background image.

imageAttributesobject

Attributes for the image element.

imagePositionstring

The position of the image, if it is a background image.

lazyloadboolean

Whether to lazyload the image or not.

spacingstring | number | Array | object

The spacing for the component, as a string, number, array, or object.

urlstring

The url of the image.

widthnumber

The width of the image, in px.

refobject | null

Ref to the component.

Since
  • 1.1.15
Returns:

Return the function image component in React.

Type: 
JSX.Element
Example
import Image from '@gravityforms/components/react/admin/elements/Image';

return (
    <Image
        asBg={ true }
        aspectRatio={ 1.5 }
        url="https://path.to.image/"
    />
);

Methods

(inner) getBackgroundImage(props) → {JSX.Element}

Get the markup in react for a background image.

Parameters:
NameTypeDescription
propsobject

Props for the background image.

Properties
NameTypeDescription
attributesobject

The attributes for the image wrapper.

imageAttributesobject

The attributes for the background image.

Since
  • 1.1.15
Returns:

The background image.

Type: 
JSX.Element

(inner) getBackgroundPosition(position) → {string}

Get the background position for the background image.

Parameters:
NameTypeDescription
positionstring

The background image position.

Returns:

The position of the background image.

Type: 
string

(inner) getImageCaption(props) → {JSX.Element}

Get the markup in react for a caption for the image component.

Parameters:
NameTypeDescription
propsobject

Props for the caption.

Properties
NameTypeDescription
childrenJSX.Element | string

React element children.

customAttributesobject

Custom attributes for the caption.

customClassesstring | Array | object

Custom classes for the caption.

Since
  • 1.1.15
Returns:

The caption for the image component.

Type: 
JSX.Element

(inner) getImageWithCaption(props) → {JSX.Element}

Get the markup in react for an image with caption.

Parameters:
NameTypeDescription
propsobject

Props for the image with caption.

Properties
NameTypeDescription
attributesobject

The attributes for the image wrapper.

captionJSX.Element | string

The caption for the image, can be a string or react children.

captionAttributesobject

The attributes for the caption element.

imageAttributesobject

The attributes for the image.

Since
  • 1.1.15
Returns:

The image with caption.

Type: 
JSX.Element