htmlbbcode

Is it possible to use HTML markup, to "force" BBCode to imbed images with specific dimensions?


I spend quite a bit of time asking questions and answering questions in allot of education/learning oriented communities. More recent forums use Markdown but there are still quite allot of forums that use BBCode as their markup interface, including my school.

To save myself some headache I use a markdown editing software (Obsidian) to write my questions/answers/replies. For those time where the destination is a BBCode forum , I want to use a shell script that takes a Markdown file as input and generates a BBCode version, saving the output to my clipboard.

The following snippet could be a markdown file, I include any media (Images or Gifs) I need, along with the dimensions:

One thing 1PP (1 Point Perspective) and 2PP (2 Point Perspective) will always have in common are the vertical lines, they are always true verticals:
![500x100](https://i.imgur.com/lTH5gg6.gif)
The above(1PP), the Y-axis of the box are paralell with the red, vertical lines. Its also the same for the below (2PP), the Y-axis of the box are paralell with the red, vertical lines
![500x100](https://i.imgur.com/ObMTgv0.gif)

The script will simply parse the Markdown file, returns an output like the following:

One thing 1PP (1 Point Perspective) and 2PP (2 Point Perspective) will always have in common are the vertical lines, they are always true verticals:
[imgwh=500,100]https://i.imgur.com/lTH5gg6.gif[/imgwh]    
The above(1PP), the Y-axis of the box are paralell with the red, vertical lines. Its also the same for the below (2PP), the Y-axis of the box are paralell with the red, vertical lines:
[imgwh=500,100]https://i.imgur.com/ObMTgv0.gif[/imgwh]   

I have written 90% of the shell script and works really well. I am stuck on finding a consistent means to resize images in BBCode. After some searching, I have learnt tags for resizing images are not a standard feature across forums that use BBCode, For example one forum supports resizing media with a tag like [imgwh] (the above example) while many others do not, you can only place an image.

Upon further search, I cam across THIS solution but its not ideal, I really need a means to be able to decide both the width and height, Also I wish to avoid abstracting dimensions to S, M, L etc.

I also experimented with FFMPEG/ImageMagick to resize media to the desired dimensions, before uploading them to a website. The results are horrendous and extremely slow, specially for gif files. I dont own a fast computer but I have a fast internet.

Is it possible to use HTML markup, to "force" BBCode to imbed images with specific dimensions? I don't know any HTML but if its possible I would learn it. If not then are there image hosting websites that you can request a size of the image in the URL itself, something like:

https://i.imgur.com/lTH5gg6_W500xH100.gif

Any help or just pointing me in the right direction, would be greatly appreciated!


Solution

  • Html can of course put the image any size you want, and it is worth a shot to try e.g. <img src="https://i.imgur.com/lTH5gg6.gif" width="500" height="100">.

    However, I think most sites won't allow direct html in bbcode (don't quote me on this though, haven't used bb code much at all), and since you don't control the site you shouldn't be able to modify the actual html which eventually displays the image.

    Did you check this out? They use both

    [img=100x50]
    

    and

    [img width="100" height="50"]
    

    to resize.

    I think you might have to accept the fact that your script will need some kind of argument to modify the output depending on the BBCode version/implementation. Like my linked site says, BBCode isn't a rigorous standard. I don't think you'll find a method which works for all BBCode.

    Then if you can't find an image hosting service like that (I couldn't with a quick google), you could always implement your own :)