UBB Codes

Started by pasab, September 02, 2009, 08:41:10 AM

Previous topic - Next topic

pasab

a very simple question, but I cant find a .
Which file provides the implementation of the ubb code? I want to do a small adjustment in a ubb code

Thanxs in advance,
   
Sorry I'm not good in English typing

Marcus Forsberg

Are you speaking of BBC (Bulletin Board Code)?
If so, Subs.php, function parse_bbc()

pasab

Yes i mean the Bulletin Board Code
But i can't find it

I want to change the img tags with a standard with and height

i have found

'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)',
),
array(
'tag' => 'img',
'type' => 'unparsed_content',
'content' => '<img src="$1" alt="" border="0" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',


Can you tell me where i need to adjust the with en height?

The idea is when you press the image icon you wil get

Marcus Forsberg

Change this part:

               'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
               'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),


               'width' => array('optional' => true, 'value' => ' width="600"', 'match' => '(\d+)'),
               'height' => array('optional' => true, 'value' => ' height="300"', 'match' => '(\d+)'),




pasab

that aind working

maybe i need to adjust somthing here ?

// Do <img ... /> - with security... action= -> action-.
preg_match_all('~<img\s+src=(?:")?((?:http://|ftp://|https://|ftps://).+?)(?:")?(?:\s+alt=(?:")?(.*?)(?:")?)?(?:\s?/)?>~i', $data, $matches, PREG_PATTERN_ORDER);
if (!empty($matches[0]))
{
$replaces = array();
foreach ($matches[1] as $match => $imgtag)
{
// No alt?
if (!isset($matches[2][$match]))
$matches[2][$match] = '';

// Remove action= from the URL - no funny business, now.
if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0)
$imgtag = preg_replace('~action(=|%3d)(?!dlattach)~i', 'action-', $imgtag);

// Check if the image is larger than allowed.
if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height']))
{
list ($width, $height) = url_image_size($imgtag);

if (!empty($modSettings['max_image_width']) && $width > $modSettings['max_image_width'])
{
$height = (int) (($modSettings['max_image_width'] * $height) / $width);
$width = $modSettings['max_image_width'];
}

if (!empty($modSettings['max_image_height']) && $height > $modSettings['max_image_height'])
{
$width = (int) (($modSettings['max_image_height'] * $width) / $height);
$height = $modSettings['max_image_height'];
}

// Set the new image tag.
$replaces[$matches[0][$match]] = '<img src="' . $imgtag . '" width="' . $width . '" height="' . $height . '" alt="' . $matches[2][$match] . '" border="0" />';
}
else
$replaces[$matches[0][$match]] = '<img src="' . $imgtag . '" alt="' . $matches[2][$match] . '" border="0" />';
}

$data = strtr($data, $replaces);

Marcus Forsberg

What exactly are you trying to do? Your last post was interupted in the middle of a sentence.

"The idea is when you press the image icon you wil get "

pasab

#6
oops i see.

The idea is that when you click at the you will get [img with=430 height=322]http://[/img]

Because when you type it yourself it working just fine, i want that its already standing there when people press the

or some changes that will automatically change the image size to with 430 height 322

And before you ask why ;ID  have a image upload script for the forum users so al the
images are at the same server as the forum (it happens al lot that somwane post a image and the image is deleted from the server, and you see a nice whit box whit a red cross) and the upload script resizes the images to with 430 height 322.

Marcus Forsberg

Oh, that's another thing.
If you are using SMF 1.1.10, please attach Post.template.php, or if you areo n SMF 2.0, Subs-Editor.php.

pasab

i'm using SMF 1.1.10

i cant find Post.template.php where should i find it  :-[

Arantor

Post.template.php is in Themes/yourtheme/, or if it's not, Themes/default/
Holder of controversial views, all of which my own.


pasab

You meen this line

'img' => array('code' => 'img', 'before' => '[img]', 'after' => '[/img]', 'description' => $txt[435]),[\code]

Marcus Forsberg

Yes. This should do it.

  'img' => array('code' => 'img', 'before' => '[img width=430 height=322]', 'after' => '[/img]', 'description' => $txt[435]),

pasab

okey,

its working now.
After i changed in the subs.phpthe with en height back to $1.

Thanxs
;) :)

Marcus Forsberg

Great! :) Topic marked as solved.

pasab

I was looking for a button to mark it as solved and i couldnt find it.
That is not my job ;)

Thanks, it's not easy to explain something is a different language but after al its al working and thas the most important.

have a nice evening

Advertisement: