I’m utilizing an UploadCare trigger in Zapier, and I need to extract the height and width of an image through a ‘Code by Zapier’ step using JavaScript.
I’m working with an input labeled Data Image Details, and here’s the code I’ve implemented:
return {dimensions: inputData.details};
.
However, the output from this test is empty. Can anyone help me identify the issue?
The issue might occur if the “Data Image Details” do not directly contain the dimensions data, or if it’s not correctly parsed. Make sure that your UploadCare integration is properly set up and that it provides image dimensions as part of the image metadata. You may want to inspect the format of “inputData.details” to ensure it includes the required properties. If it’s a JSON object, you should access the specific fields for height and width using something like inputData.details.width and inputData.details.height within your code.
In my experience, when working with UploadCare and Zapier, the trick sometimes lies in the response format and how Zapier handles it. If the image details seem empty, double-check if the output of the trigger is an array or an object. Sometimes the data might be nested deeper than expected. Try running console.log(typeof inputData.details) to verify if it’s giving you the expected type. If it’s an array, access it properly via index. Otherwise, ensure that your input source isn’t missing properties due to permissions or configuration settings that prevent full access.
Sometimes it’s just the formatting. Double-check if the input data is not a stringified JSON object. If it is, parsing it with JSON.parse() might resolve your issue. Also, ensure all data paths match the actual structure of the JSON object returned from UploadCare.
One potential issue could be how the data is being passed to the Code by Zapier step. Even if your inputData.details includes dimensions, they might be nested or need additional processing. I had a similar issue before and realized I needed to unpack the payload with
var details = JSON.parse(inputData.details);
before accessing the width and height. Also, if you’re getting empty results, try logging intermediate steps with console.log(details) to verify what’s actually being received and ensure you’re accessing the information correctly.