[SOLVED] Improving [IMG] BBCode tag

Started by Rajven, September 09, 2008, 07:25:20 AM

Previous topic - Next topic

Rajven

Hi all!

I was wondering why the [img][/img] tag have only 2 option, width & height, and not something like align. I think it's useful.
So I searched here and there in the smf files and and I found in the Subs-Post.php the part that seems to be to modify.

// Fix any URLs posted - ie. remove 'javascript:'.
function fixTags(&$message)
{
global $modSettings;

// WARNING: Editing the below can cause large security holes in your forum.
// Edit only if you are sure you know what you are doing.

$fixArray = array(
// [img]http://...[/img] or [img width=1]http://...[/img]
array(
'tag' => 'img',
'protocols' => array('http', 'https'),
'embeddedUrl' => false,
'hasEqualSign' => false,
'hasExtra' => true,
),


Is that the right place AND file? I'm a bit worried to modify something that is in the "Sources" directory :P

Thanks for every tips!

Rajven


Rajven


karlbenson


Rajven

I've finally managed to modify the [img] tag to get other parameters!

In Subs. php in the function parse_bbc (like suggested ;) ) from this:
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} border="0" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),


I made into this:
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
          'align' => array('optional' => true, 'value' => ' align="$1"', 'match' => '(left|right|middle|top|bottom)'),
          'hspace' => array('optional' => true, 'value' => ' hspace="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height}{align}{hspace} border="0" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),


I alsa add the HSPACE param ;) sometimes it's useful!

Thanks for the support!

Advertisement: