Working with Resources
Resource Object Structure
{
image: "/path/to/image.jpg", // Path to the image file
width: 1920, // Original width in pixels
height: 1080, // Original height in pixels
aspect: "16/9", // Aspect ratio string
alt: "Image description", // Alt text
format: "jpg" // File format
}Accessing Resources
const transformHook = (rw) => {
const { image, backgroundImage } = rw.props;
// Check if resource exists and has an image
const hasImage = image && image.image;
if (hasImage) {
console.log(image.image); // "/resources/my-image.jpg"
console.log(image.width); // 1920
console.log(image.height); // 1080
}
rw.setProps({
hasImage,
imageSrc: hasImage ? image.image : null,
imageAlt: hasImage ? image.alt : ''
});
};
exports.transformHook = transformHook;Resizing Images
Retina/HiDPI Support
Responsive Images
Gallery Resources
Placeholder Images
Background Images
Last updated
Was this helpful?

