BBcode that generates an image gallery

Get help developing custom BBCodes or request one.
Post Reply
Elya
Registered User
Posts: 15
Joined: Thu Sep 06, 2018 8:31 am

BBcode that generates an image gallery

Post by Elya »

Hi guys,

I'm trying to put together a code that would allow me to :

- automatically list the image files from a given directory on my server
- get the list back as a string
- use that string to generate a gallery image

The BBcode itself would look like this:

[gallery]folder_name[/gallery]

So I managed to write the code in PHP that returns the list of image files from a directory. The code is in a php file that I have uploaded to my ./forum directory. When displaying that PHP page in my browser, I can see the list of the image items, each separated with a comma.

I wrote a JavaScript function that takes two arguments : the name of the folder (which contains the images) and the list of image names separated with a comma.

But I couldn't go any further as I haven't found a way to use the result of the PHP file (the list of images) with my JavaScript function (the one that generates the image gallery). Since the page has to be reloaded when the form is submitted when someone posts a message on the board, I thought there would be no problem using PHP with JS and there would be no need for Ajax. But I'm not really familiar with these things so help would be greatly appreciated, thanks!
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26505
Joined: Fri Aug 29, 2008 9:49 am

Re: BBcode that generates an image gallery

Post by Mick »

The fact that you're using an external file goes against the mo for custom BBCodes. The idea is that an admin can install a bbcode on his board without requiring programming or extra files. In any case, I think you'd be better off making an extension for this, you seem well up on the coding side of things, or you can make an extension request as this seems over the top for a custom bbcode.
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
Post Reply

Return to “Custom BBCode Development and Requests”