rokked
04-25-2007, 10:00 PM
Auto Resize Images when they're Quoted
Test with: 3.6.5
This is a pretty basic add on and also my first add on. If you see anything messed up in the code or something that could be done better, please comment and I'll fix it. I'm relatively new to the add-on scene, so there could be better ways to do this.
What does this mod do?
images that get posted within the QUOTE tag will be resized to a width of 100.
thumbnails will link to the url of the actual image.
Installation:
open includes/class_bbcode.php
find:
$template = $this->printable ? 'bbcode_quote_printable' : 'bbcode_quote';
eval('$html = "' . fetch_template($template) . '";');
return $html;
}
replace with:
$template = $this->printable ? 'bbcode_quote_printable' : 'bbcode_quote';
eval('$html = "' . fetch_template($template) . '";');
//### RESIZE IMAGES IN QUOTE TAGS
if ($this->contains_bbcode_img_tags($html))
{
$html = preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "\$this->handle_bbcode_timg(str_replace('\\\"', '\"', '\\1'), '')", $html);
}
//### RESIZE IMAGES IN QUOTE
return $html;
}
find:
function handle_bbcode_img_match($link)
{
$link = $this->strip_smilies(str_replace('\\"', '"', $link));
// remove double spaces -- fixes issues with wordwrap
$link = str_replace(' ', '', $link);
return '<img src="' . $link . '" border="0" alt="" />';
}
underneath that paste the following:
function handle_bbcode_timg($link)
{
$link = $this->strip_smilies(str_replace('\\"', '"', $link));
// remove double spaces -- fixes issues with wordwrap
$link = str_replace(' ', '', $link);
return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" width="100" alt="" /></a>';
}
Save & Upload.
That should be it. Hopefully it works for you!
Test with: 3.6.5
This is a pretty basic add on and also my first add on. If you see anything messed up in the code or something that could be done better, please comment and I'll fix it. I'm relatively new to the add-on scene, so there could be better ways to do this.
What does this mod do?
images that get posted within the QUOTE tag will be resized to a width of 100.
thumbnails will link to the url of the actual image.
Installation:
open includes/class_bbcode.php
find:
$template = $this->printable ? 'bbcode_quote_printable' : 'bbcode_quote';
eval('$html = "' . fetch_template($template) . '";');
return $html;
}
replace with:
$template = $this->printable ? 'bbcode_quote_printable' : 'bbcode_quote';
eval('$html = "' . fetch_template($template) . '";');
//### RESIZE IMAGES IN QUOTE TAGS
if ($this->contains_bbcode_img_tags($html))
{
$html = preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "\$this->handle_bbcode_timg(str_replace('\\\"', '\"', '\\1'), '')", $html);
}
//### RESIZE IMAGES IN QUOTE
return $html;
}
find:
function handle_bbcode_img_match($link)
{
$link = $this->strip_smilies(str_replace('\\"', '"', $link));
// remove double spaces -- fixes issues with wordwrap
$link = str_replace(' ', '', $link);
return '<img src="' . $link . '" border="0" alt="" />';
}
underneath that paste the following:
function handle_bbcode_timg($link)
{
$link = $this->strip_smilies(str_replace('\\"', '"', $link));
// remove double spaces -- fixes issues with wordwrap
$link = str_replace(' ', '', $link);
return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" width="100" alt="" /></a>';
}
Save & Upload.
That should be it. Hopefully it works for you!