PDA

View Full Version : Modifying built in bb codes


tommythejoat
04-24-2009, 02:22 PM
The built in IMG bb code does not provide a means to specify the alt text string that goes with the image.

I can write an IMG bb code that works correctly to use the {option} variable to receive the alt text. It would work like: http://url_for_image.gif.

Can I just create this bb code in custom bb codes and have it replace the built in bb code, or does that require some other hack somewhere?

TigerC10
04-24-2009, 08:08 PM
If you create an custom IMG bbcode, as long as you set it to use the option variable it will do what is called "overloading". bbCode overloading means that you have two bbcodes with the same name, but one of them uses an option and the other doesn't. In this way, people can still use the bbCode without the option, or with it.

tommythejoat
04-25-2009, 12:01 AM
Jake answered this quesion on vBulletin.com about the same time as you did here.

I put in the bb code, but there is still a bit of a problem.

The parser stops when it sees the first space in the option string. Quotes of either kind, curly's, &nbsp, %20 and so forth do not help. I don't know if I want to fool with the parser, but the option token should be parsed to the closing square bracket, I believe.

Jake suggested that I ask someone here to tell me how to fix the code in the parser.

TigerC10
04-25-2009, 01:49 PM
You have it backwards. You should reverse it. Make the Option Code into the IMG URL and the text in the value section. This way it's just like the URL bbCode...

http://www.google.com
The All Knowing Google (http://www.google.com)

https://vborg.vbsupport.ru/external/2009/04/7.gif
Google's Logo

Can you dig it?

tommythejoat
04-25-2009, 03:00 PM
You are right that the change would work. However, it would then be very different from the native IMG code. Maybe that doesn't really matter.

I was thinking of it as a modification of the existing code. I could just make up a new name entirely and avoid any confusion.

TigerC10
04-25-2009, 07:20 PM
You are right that the change would work. However, it would then be very different from the native IMG code. Maybe that doesn't really matter.

I was thinking of it as a modification of the existing code. I could just make up a new name entirely and avoid any confusion.

I think you won't have that problem. See, by doing it that way - you're keeping with the standards set by the URL bbCode. This makes more sense to a lot of people since you would be treating them both the same way.

If you really wanted to modify the way the IMG bbCode is handled, you can try using a plugin... But it would be overly complicated and unnecessary.