Image Upload as Topic
-
Hi All,
Very impressed with what we've been able to figure out on our own via documentation. It seems we've hit something that either is not complete (so does not work) or it has been removed from NodeBB.
What we are attempting to do is create an image board of sorts, but with all the cool features that NodeBB provides included. We figured out how to mass/batch created categories, but what we need to do now is mass/batch upload images as topic posts. Essentially, we want the image to be the initial post to be discussed about, voted on, etc.
We found a few places online and in your documentation that tries to explain how to do something similar, but we have not found anything that describes precisely what we are wanting to do.
curl -H "Authorization: Bearer 000000-0000-0000-0000-000000000000" -XPOST --data "files=/opt/nodebb/day.jpg" http://localhost:4567/api/topic/upload/thumb
This was the last attempt that did not work.
Note, we don't want to simply upload files. We want to insert these images into posts or as the posts. We would like to do this in batches.
Is this possible on the current API release? If not, is this something in the works or would it be a feature request?
Thank-you,
Jeff -
@julian mind taking a look?
-
@pitaj Thank-you.
We might have come across a method to do what we want, but it is going to take a bit more engineering to perfect things. We found a plugin called Imgbed that takes one of three options for embedding images into topics...markdown, bbcode, or html.
With a properly formatted curl command we should be able to mass create topics using a simple content entry and some variable magic. Once the plugin is installed and activated, we can fill the content requirement with bbcode links to all of our images.
curl -H "Authorization: Bearer 000000-0000-0000-0000-0000000000" -XPOST --data 'cid=35&title=fake post&content=![image-url.jpg| ](/assets/uploads/files/1633832725245-page-layout.jpg)' http://localhost:4567/api/v3/topics
The above curl command uses the bbcode method for embedding an image. The image is located or will be located under /assets/uploads.
As we keep trying, it will be interesting to hear what Julian says.
Jeff
-
@jpop71 that's markdown. Bbcode would look like
[img]https://www.bbcode.org/images/lubeck_small.jpg[/img]
. You likely don't need the plugin at all. -
Looking to solve this problem as well.
Seems this method only creates a hyperlink as the content of the Topic post
Where is this guys solution at least renders the image as the body within the content of the Topic post.
both of these presume the image source is available via HTTP.
What if the file are on the filesystem? file:// doesn't seem to work as the [img] doesn't invoke the upload process.
From a review of the API it seems to post via API one has to upload the image first to assure the file is in the assets directory then a second API call to associate the asset URI to a Topic.
Since ![image-url] and [img] are limited i'm not seeing a clear path forward as i'd like nodebb to 'own' the content.
We've hobbled together a script to mass post via ![image-url] and visually it's what we'd like but again it's function is deponent upon the provided HTTP server being available. -no sad panda.
pls advise
-
@unfufadoo uploading the photos to NodeBB and then adding them to the post with
![image]
does have NodeBB own the image.We've hobbled together a script to mass post via ![image-url] and visually it's what we'd like but again it's function is deponent upon the provided HTTP server being available. -no sad panda.
Accessing NodeBB in the first place requires the http server be available. I don't know what the problem is.
-
@unfufadoo no, if you use the correct markdown for an image embed, it will show the actual image.
The leading
!
is important. Example:![burger](https://i.imgur.com/z9Sp1WS_d.webp?maxwidth=640&shape=thumb&fidelity=medium)
Without it, just a link:
[burger](https://i.imgur.com/z9Sp1WS_d.webp?maxwidth=640&shape=thumb&fidelity=medium)
-
Right, that's easy however rather than http:// I need file:// to work.
Also note this is visually the intended result which can be achieved however the image itself is served from the provided http source.
In my use case it's intended the http source go away. I have at a OS file system level the contents of the old http source of the images. I would like to use file:// so that nodebb 'owns' the source files rather than just have content of http hyperlink
PS. that's a darn good looking burger.
-
@unfufadoo I'm still really confused on what you're trying to accomplish.
Do you mean you just want
file://
to show up in the post content but the image is still served in the browser over http?In my use case it's intended the http source go away. I have at a OS file system level the contents of the old http source of the images. I would like to use file:// so that nodebb 'owns' the source files rather than just have content of http hyperlink
I cannot figure out what you're trying to say. A
file://
resource points to a location on the file system of the user. So if your browser even allows that, it could point to a different file or a missing file depending on what computer is loading the page.What do you mean by "old http source of the images"?
It doesn't sound like
file://
is what you want. You said earlier:The difference is the contents is a hyperlink to the referenced image and not processed like an upload via the composer.
But this is wrong. When you add a picture with the composer, the file is first uploaded to be hosted by NodeBB, and then a relative link to the file is added to the post.
This is identical to the way you do it with the API. Upload the image file, then create a post with a link to the image.
-
@pitaj We are trying to simply migrate 1000's of images from a mounted filesystem into NodeBB, but we want the images to be the post and owned by NodeBB when we are done. So the image should be embedded, not linked, and show up as the main thing to discuss in the forum.
-
You can avoid the upload step by copying the images directly to
nodebb/public/uploads/migrated
and then embedding them like![image](/assets/uploads/migrated/image.jpg)