View Full Version : Custom [ IMG ] BBCODE
DF031
02-08-2013, 07:45 AM
Good morning all,
I would like deep-linked images to stand-out more, so moderators can spot them and ask the user to upload it.
I assume a deep-linked image is always "inserted" by using the [ IMG ] [ /IMG ] bbcode
Would it be possible to change that bbcode so the image would have, for instance, a red border ?
LifesGreatestGift
02-09-2013, 03:13 AM
New Plugin
Name: Add border to external image in posts
Hook Location: postbit_display_complete
/* Show only moderator,super moderator, administrator */
if (is_member_of($vbulletin->userinfo, 5,6,7)) {
/* Get post content */
$html = $this->post['message'];
/* Get base URL of site */
$site_url = $_SERVER['HTTP_HOST'];
/* If site base URL contains WWW, remove */
if (strpos($site_url,'www.') !== false) {
$site_url2 = substr($site_url, 4);
} else {
$site_url2 = $site_url;
}
/* Load post content for parsing */
$doc = new DOMDocument();
@$doc->loadHTML($html);
/* Select all img elements */
$tags = $doc->getElementsByTagName('img');
/* Iterate over array of img elements to review src (sources) */
foreach ($tags as $tag) {
/* Select 'src' of img element */
$img_src = $tag->getAttribute('src');
/* If 'src' doesn't contain site base URL, apply 'external-img' class */
if (strpos($img_src,$site_url2) === false) {
$this->post['message'] = str_replace($img_src, $img_src . '" class="external-img', $this->post['message']);
}
}
}
now add this to additional.css template
.external-img {
outline: 2px solid #FF0000;
border: 2px solid #FFF;
margin: 6px;
}
The only downside with this is, that it does not account for relative images. aka
<img src="images/smilies/smile.png" />
relative images will be seen as external.
--------------- Added 1360413856 at 1360413856 ---------------
I forgot to change
if (is_member_of($vbulletin->userinfo, 6)) {
To
if (is_member_of($vbulletin->userinfo, 5,6,7)) {
LifesGreatestGift
02-09-2013, 09:53 PM
yes, i didnt feel like researching how to change relative url's to full forum urls. but its possible. I would just edit the editor files to make the image paths absolute instead of relative. only downside would be upgrading, you would need to do the edits again. maybe someone will edit the plugin code i provided to set relative urls to full and omit them from the 'replace'.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.