Skip to content

Commit 93cffc0

Browse files
feat: add possibility to fetch fallback image size
1 parent 424bd93 commit 93cffc0

12 files changed

Lines changed: 145 additions & 31 deletions

File tree

apps/csk-marketing-site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@uniformdev/csk-marketing-site",
3-
"version": "6.0.86",
3+
"version": "6.0.87",
44
"private": true,
55
"engines": {
66
"yarn": "please-use-npm",

apps/csk-storybook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@uniformdev/csk-storybook",
3-
"version": "6.0.86",
3+
"version": "6.0.87",
44
"description": "CSK vNext Storybook is an interactive Storybook build showcasing components from the CSK vNext component starter kit. It provides detailed documentation, live previews, and testing capabilities for easy integration into your projects.",
55
"main": "index.js",
66
"scripts": {

apps/csk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@uniformdev/component-starter-kit",
3-
"version": "6.0.86",
3+
"version": "6.0.87",
44
"private": true,
55
"engines": {
66
"yarn": "please-use-npm",

package-lock.json

Lines changed: 116 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "csk-packages",
3-
"version": "6.0.86",
3+
"version": "6.0.87",
44
"private": true,
55
"scripts": {
66
"build": "turbo build",

packages/csk-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@uniformdev/csk-cli",
3-
"version": "6.0.86",
3+
"version": "6.0.87",
44
"description": "Command-line interface (CLI) tool designed to streamline the development workflow within Uniform projects. It provides commands for pulling additional data and generating components based on Canvas data",
55
"license": "SEE LICENSE IN LICENSE.txt",
66
"engines": {

packages/csk-components/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@uniformdev/csk-components",
3-
"version": "6.0.86",
3+
"version": "6.0.87",
44
"description": "Components Starter Kit that provides a set of basic components for building websites within a Uniform project",
55
"license": "SEE LICENSE IN LICENSE.txt",
66
"engines": {
@@ -70,16 +70,18 @@
7070
"next-themes": "^0.4.4",
7171
"ora": "^8.1.1",
7272
"prettier": "3.5.2",
73+
"probe-image-size": "^7.2.3",
7374
"react-player": "^2.16.0",
7475
"react-responsive-masonry": "^2.7.0",
7576
"tailwind-merge": "^2.5.2"
7677
},
7778
"devDependencies": {
7879
"@repo/eslint-config": "*",
7980
"@repo/typescript-config": "*",
80-
"@uniformdev/assets": "^20.20.3",
81-
"@uniformdev/canvas": "^20.20.3",
82-
"@uniformdev/canvas-next-rsc": "^20.20.3",
81+
"@types/probe-image-size": "^7.2.5",
82+
"@uniformdev/assets": "^20.20.0",
83+
"@uniformdev/canvas": "^20.20.0",
84+
"@uniformdev/canvas-next-rsc": "^20.20.0",
8385
"next": "^15.3.2",
8486
"react": "^19.1.0",
8587
"react-dom": "^19.1.0",

packages/csk-components/src/components/canvas/Image/image.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { FC } from 'react';
2+
import probe from 'probe-image-size';
23
import { imageFrom } from '@uniformdev/assets';
34
import BaseImage from '@/components/ui/Image';
45
import { resolveAsset } from '@/utils/assets';
56
import { ImageProps } from '.';
67
import { ImagePlaceholder } from './placeholder';
78

8-
export const Image: FC<ImageProps> = ({
9+
export const Image: FC<ImageProps> = async ({
910
image,
1011
objectFit,
1112
width,
@@ -28,6 +29,14 @@ export const Image: FC<ImageProps> = ({
2829

2930
const { focalPoint, title = '' } = resolvedImage;
3031

32+
const imageWidth = width || resolvedImage.width;
33+
const imageHeight = height || resolvedImage.height;
34+
35+
const fallbackSize =
36+
(!imageWidth || !imageHeight) && resolvedImage.url
37+
? await probe(resolvedImage.url).catch(() => ({ width: undefined, height: undefined }))
38+
: { width: undefined, height: undefined };
39+
3140
const imageUrl = imageFrom(resolvedImage?.url)
3241
.transform({
3342
width: width,
@@ -39,7 +48,10 @@ export const Image: FC<ImageProps> = ({
3948

4049
const variantBasedProps = isBackground
4150
? { fill: true }
42-
: { width: width || resolvedImage.width, height: height || resolvedImage.height };
51+
: {
52+
width: imageWidth || fallbackSize.width,
53+
height: imageHeight || fallbackSize.height,
54+
};
4355

4456
return (
4557
<BaseImage

packages/csk-recipes/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@uniformdev/csk-recipes",
3-
"version": "6.0.86",
3+
"version": "6.0.87",
44
"description": "command-line interface (CLI) and utility functions to help you work with recipes in a CSK project. It simplifies project initialization by allowing you to choose templates and include specific recipes",
55
"license": "SEE LICENSE IN LICENSE.txt",
66
"engines": {

0 commit comments

Comments
 (0)