kasperlegarth/instastory.js

Issue with images without caption

elemis opened this issue · 2 comments

If no captions are available, the script returns an error for line 85 saying:

TypeError: undefined is not an object (evaluating 'post.edge_media_to_caption.edges[0].node')

line 85:
"{{caption}}": post.edge_media_to_caption.edges[0].node.text,

Please check http://themes.iki-bir.com/instastory/ for demonstration.

Is there a way to fix this issue?

Hi @elemis,
Thanks for the feedback. I'll look into making a fallback to prevent the error.

Hi @elemis,
I have fixed the issue. And pushed the code to the master.
Alternative you can change line 85 to this: "{{caption}}": ((post.edge_media_to_caption.edges.length > 0) ? post.edge_media_to_caption.edges[0].node.text : ""),

Also, i just noticed how long it was since you made this issue. Sorry for the long response time, somehow i have turned notifications off.

Let me know if there is anything else i can help you with 👍