I am return in array of images from web pages and using the the first image to post to facebook.
{{ $json.message.content.ProductImagesArray[0] }}
Sometimes the image url is in correct. How do I say:
If {{ $json.message.content.ProductImagesArray[0] }} is false use https:///www.mywebsite/newsItem.png
n8n
October 11, 2024, 2:35pm
2
It looks like your topic is missing some important information. Could you provide the following if applicable.
n8n version:
Database (default: SQLite):
n8n EXECUTIONS_PROCESS setting (default: own, main):
Running n8n via (Docker, npm, n8n cloud, desktop app):
Operating system:
Hey @Steve_Warburton , what does âimage url is in correctâ imply? Do you mean it has something different then ending with something like â.pngâ or â.jpgâ? Could you be me specific and maybe give us some examples of an incorrect URL? Secondly, what ânewsItem.pngâ should be for different wrong URL, is it always the same?
I have added another http node and added the image url.
{{ $json.message.content.ProductImagesArray[0] }}
In settings I added continue with url errors.
Change method to header
Then use a set node to change the value of url
{{ $(âOpenAI2â).item.json.message.content.ProductImagesArray[0] ? $(âOpenAI2â).item.json.message.content.ProductImagesArray[0] : âhttps://www.rockstruck.com/videoThumbnails/logo20.png â }}
So if the initial request does not bring a url or the url is wrong I post a std image.
1 Like
Thanks @Steve_Warburton , there is a simpler expression that might work the same. It could look like below
{{ $('OpenAI2').item.json.message.content.ProductImagesArray?.[0] ?? 'https://www.rockstruck.com/videoThumbnails/logo20.png' }}
system
Closed
October 18, 2024, 5:03pm
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.