Skip to content

Commit 711c759

Browse files
authored
feat: Log x-cld-error on image error (cloudinary-community#553)
# Description This uses the result of pollForProcessingImage to log the value of x-cld-error if there's an error. ## Issue Ticket Number Fixes cloudinary-community#512 <!-- Specify above which issue this fixes by referencing the issue number (`#<ISSUE_NUMBER>`) or issue URL. --> <!-- Example: Fixes https://github.com/cloudinary-community/next-cloudinary/issues/<ISSUE_NUMBER> --> ## Type of change <!-- Please select all options that are applicable. --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Fix or improve the documentation - [ ] This change requires a documentation update # Checklist <!-- These must all be followed and checked. --> - [ ] I have followed the contributing guidelines of this project as mentioned in [CONTRIBUTING.md](/CONTRIBUTING.md) - [ ] I have created an [issue](https://github.com/cloudinary-community/next-cloudinary/issues) ticket for this PR - [ ] I have checked to ensure there aren't other open [Pull Requests](https://github.com/cloudinary-community/next-cloudinary/pulls) for the same update/change? - [ ] I have performed a self-review of my own code - [ ] I have run tests locally to ensure they all pass - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes needed to the documentation
1 parent 80a6abb commit 711c759

4 files changed

Lines changed: 14 additions & 39 deletions

File tree

next-cloudinary/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"dependencies": {
1919
"@cloudinary-util/types": "1.5.10",
2020
"@cloudinary-util/url-loader": "5.10.4",
21-
"@cloudinary-util/util": "^3.3.2"
21+
"@cloudinary-util/util": "4.0.0"
2222
},
2323
"devDependencies": {
2424
"@babel/core": "^7.25.2",

next-cloudinary/src/components/CldImage/CldImage.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ const CldImage = forwardRef<HTMLImageElement, CldImageProps>(function CldImage(p
128128
const image = options.target as HTMLImageElement
129129
const result = await pollForProcessingImage({ src: image.src })
130130

131-
if ( result ) {
131+
if ( typeof result.error === 'string' && process.env.NODE_ENV === 'development' ) {
132+
console.error(`[CldImage] Failed to load image ${props.src}: ${result.error}`)
133+
}
134+
135+
if ( result.success ) {
132136
setImgKey(`${defaultImgKey};${Date.now()}`);
133137
}
134138
}

next-cloudinary/src/components/CldUploadWidget/CldUploadWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const CldUploadWidget = ({
103103
const isSuccess = results.event === 'success';
104104

105105
if ( isSuccess && typeof onUpload === 'function' ) {
106-
if ( process.env.NODE_ENVIRONMENT === 'development' ) {
106+
if ( process.env.NODE_ENV === 'development' ) {
107107
console.warn('The onUpload callback is deprecated. Please use onSuccess instead.');
108108
}
109109
onUpload(results, widget.current);

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)