PDA

View Full Version : parsing [IMG] tags?


Mikhailtech
12-06-2007, 01:40 AM
Hi,

I'm trying to figure out if there's a way to specifically parse [ IMG ] tags when you parse BB code to HTML.

In particular, once the code is parsed I want every parsed image to have a 1 pixel black border around it and be centered on the page. Is there a way to do this?

Right now I'm having to do it the hard way (manually centering the image in the VB post and adding a custom BB code I made for the border).

Mythotical
12-06-2007, 01:49 AM
This is only a suggestion as I have not tested it:

Open class_bbcode.php
find:
<a href=\"{$this->registry->options['bburl']}/attachment.php?{$this->registry->session->vars['sessionurl']}attachmentid=\\1&amp;d=$attachment[dateline]\" $addtarget><img src=\"{$this->registry->options['bburl']}/attachment.php?{$this->registry->session->vars['sessionurl']}attachmentid=\\1&amp;thumb=1&amp;d=$attachment[thumbnail_dateline]\" class=\"thumbnail\" border=\"0\" alt=\""
. construct_phrase($vbphrase['image_larger_version_x_y_z'], $attachment['filename'], $attachment['counter'], $attachment['filesize'], $attachment['attachmentid'])
. "\" " . (!empty($align) ? " style=\"float: $align; margin: 2px\"" : 'style="margin: 2px"') . " /></a>

From that line down you will find quite a few entries referring to [img] bbcode.

Then alter how you see fit with border and such. Hopefully it will do what you want.

If I am wrong in this suggestion, someone please correct me.

Mikhailtech
12-06-2007, 01:51 AM
I'm totally lost looking at that code. Where exactly would I insert the modifications?

And I'm guessing class_bbcode.php is what's used for parsing?

Mythotical
12-06-2007, 01:53 AM
Yes, notice in the code I gave you, its basic html, find border and alter it how you see fit. Ignore the php code, just look at the html since what you want to do is add html.

If you still get confused I can try to alter it all but it will be alot of code replacing.

Mikhailtech
12-06-2007, 03:09 PM
Awesome, thanks for the tip! I got it working just altering 2 lines of code (adding a "1" to the border and using < center > tags to automatically center all non-smilie images).

Mythotical
12-06-2007, 05:36 PM
Great, glad to hear it.

Mikhailtech
12-14-2007, 01:50 AM
Actually I noticed a small issue. On line 1945 (or close to it) :

return '<img src="' . $link . '" border="1" alt="" />';

If I change it to:

return '<center><img src="' . $link . '" border="1" alt="" /></center>';

it does end up centering every image, but for some reason I can't figure out it also adds additional line breaks every time the post is edited. I can't figure out why this is happening. Is there another way to automatically center all images or does it have to be done manually via the WYSIWYG?