Dhaiwat10/react-link-preview

Fallback does not trigger when returned string "null"

gjsyme opened this issue ยท 5 comments

Attempting to use this for the D_D resources page and it has some records that are returned with "null" or local links ("/static/whatever...") that result in a blank box but not the fallback.

Should be fixed now.

The fallbackURL works but I'd like to make use of the fallback element. This fails due to the fact that you are getting a response ("null" or a relative path as above) so meta is not falsey. I still can't get past node-sass and node-gyp to try to resolve this myself. We can probably just generate an image but I'd rather just have it be the JSX, if possible.

I recommend a modification to (also) check that (res.image!==undefined && res.image!=="null" && !res.images.startsWith('/')) in isValidResponse (line 13 of LinkPreview.tsx

@gjsyme pushed out a new release. Let me know it helped

This is certainly better (will use the default image you have set here) but I really want to use the fallback property as then I can have something like "There is no image for this resource \n DEVDAO logo or meme \n But the article is there, we promise" or something to that effect.
It really just hinges on the fact that meta doesn't have to be null to have a bad image link which is the condition for displaying fallback from my read of your code. Thanks again for the quick changes on this thus far, and I think the link icon is at least enough to get another commit out.

It really just hinges on the fact that meta doesn't have to be null to have a bad image link

Yeah, I noticed that in one of the links. I'm gonna have a look at this & get back to you. Also, let's discuss this further via screen-sharing in the next website meeting so that we are on the same page.