[nodebb-plugin-imgbed] Image Embedding with only a URL
-
I've made a few improvements to the plugin, including allowing custom extensions to be specified, and uploading to the server when an image is linked. I had some issues when in the downloading case: The post would be parsed, and the local url would be returned, but it was before the file was actually downloaded, so the image would show up as broken when you post an image. The way I resolved it was using the websockets, and signaling the client when the file was finished downloading.
I welcome any comments or concerns about the code, especially before I publish it to npm. I do still have a few more ideas for this plugin (progress bar, maybe making an option where the conversion to a local url can be made permanent, imgur uploading)... I remember that @psychobunny mentioned incorporating a CDN but that sounds like something for a separate plugin, to handle all other types of uploads.
-
Also, is there a global debug flag that you can reference on the server side?
-
Right, and the advantage that the markdown has is that the link doesn't need to have a specific format of matching the pattern of http*jpg|gif|png etc. I could change it to parse looking for img tags, and downloading those URLs
-
Oh this is cool, I never realized that you actually fetch the image and save a copy to your server. So potentially you could do something like GitHub does (ie. host all images on your own CDN), so you don't have to worry about serving non-secure images from random sites when you're on SSL
-
@psychobunny said:
...so you don't have to worry about serving non-secure images from random sites when you're on SSL
Yep, exactly. Well that and I didn't like that an image takedown would make my forum look crappy.
@Albus are you referring to the upload capability or the imgurl capability?
-
-
I hadn't had the chance to look into any sort of integration with imgur, so sorry about that! If anyone wants to take a stab at that for now I would be paying attention to any pull requests
-
I found a bug, but when I headed over to GitHub the files are totally different so I'll tell you here...
Valid URL: http://oyster.ignimgs.com/wordpress/stg.ign.com/2014/09/TWDS5_2Sht_FM3_2.jpg?q=fhye
the above should work, but it doesn't due to the dots in stg.ign.com and the query string, I've changed the library.js file to be more liberal:
regexStr = '<a href="(https?://.+\.(' + extensions.join('|') + ')).*">[^<]*<\/a>';
Should anyone else have this problem, then that'll work for you!