shahednasser / cross-post

Cross Post a blog to multiple websites

Home Page:https://www.npmjs.com/package/cross-post-blog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Detect Image Type and Covert it

andrasbacsai opened this issue · comments

Trying to cross-post from hashnode to dev.to, but received the following error:

Error occured while cross posting to DEV: Main image is not a valid URL

The image is base64 encoded: Error: Could not load img: "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="

Thank you for reporting this. I guess the approach should be to detect if an image URL is a data URL and then get a URL for it. Another approach would be to allow an option in the CLI to enter an image URL to be used instead of scanning the article for the image.

Thank you so much for the great tool! I had gotten this problem as well. I had received these errors

Error: Could not load img: "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="

and

Error occured while cross posting to DEV: Main image is not a valid URL

I suppose that for now, I'll be posting on Dev.to and crossposting to Hashnode. Thank you again.

Hello @sjkorvin thank you for your comment on this. Unfortunately, I haven't been able to get into this due to my busy schedule, but I'm aware of what the problem is.

The tool currently only takes the src of the first image it encounters in an <article> element. Then, that src is used as the URL of the image when posting to the different platforms. It does not check what the type of image is, however, DEV is very particular about the type of images accepted, which causes the error.

I'm hoping that soon either someone will want to be assigned to work on this or I'll get some time to look into it. Maybe adding a few options here and there would more helpful, as well.

This issue has now been resolved by providing different options to the tool. You can check the README for more info