vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   New BB tag to do image thumbnails... (https://vborg.vbsupport.ru/showthread.php?t=50882)

Zzed 03-28-2003 06:48 PM

That is the line number in an unmodified functions.php for version 2.2.9.

It is the last few lines of bbcodeparse2() function.

Or if you search for the following line:

// ###################### Start phphighlite #######################

and scroll up about 6-7 lines you will get there. ;)

Pikok 03-29-2003 12:08 AM

Quote:

03-27-03 at 10:09 PM colicab-d said this in Post #9
how would i saw replace the image code with this? or even better add a THUMB button beside the IMG one?
To add a button you would need to edit 3 things.. The "vbcode_buttons" template, and the two JavaScripts "vbcode.js" and "vbcode_language.js".


In the "vbcode_buttons" template add this where you want the button to appear:
Code:

<input type="button" class="bginput" value="THUMB" title="Insert Thumbnail" onclick="vbcode(this.form,'THUMB','http://')" onmouseover="stat('thumb')">
In the "vbcode.js" you would need to add this just after the code for the IMG tag:
Code:

// *******************************************************

function vbcode(theform,vbcode,prompttext) {
// insert [x]yyy[/x] style markup
        if ((normalmode(theform)) || (vbcode=="THUMB")) {
                inserttext = prompt(tag_prompt+"\n["+vbcode+"]xxx[/"+vbcode+"]",prompttext);
                if ((inserttext != null) && (inserttext != ""))
                        theform.message.value += "["+vbcode+"]"+inserttext+"[/"+vbcode+"] ";
                }
        else {
                donotinsert = false;
                for (i = 0; i < tags.length; i++) {
                        if (tags[i] == vbcode)
                                donotinsert = true;
                        }
                if (donotinsert)
                        stat("already_open");
                else {
                        theform.message.value += "["+vbcode+"]";
                        arraypush(tags,vbcode);
                        }
                }
        theform.message.focus();
}

In the "vbcode_language.js" you would need to add this just after the code for the "img_text":
Code:

thumb_text = "Insert a thumbnail into your message";
;)

Larry@IOG 03-30-2003 12:20 AM

How would I go about just getting my IMG tag to auto thumb every image?

I have my attachments like that already

Thanks

Larry

ivanmcp 04-01-2003 12:47 PM

Hi, this is cool hack.

I presume that I can change size of a thumbnail to my own prefference. So, for example, I might want to set image width to 600 max (so not to loose table formating), and any image larger that that would be scaled down to 600 pixels width, with the option to display original image size when clicked on appropriate link.

If so, I will implement this hack immediately :).

Oh yes, I got to use this smiley :banana: .


Ivan

Rose 04-06-2003 04:07 PM

Great hack. :D I'm using it very nicely in a gallery-type format.

Is there a way to cache the images after initial loading, by chance?

Anyway, great hack and very useful.

NuclioN 04-06-2003 04:52 PM

Great Pikok. What is the code to place a thumb button by the quick reply in showtread template?

Classy 04-06-2003 08:49 PM

Thank you ... works in 2.3.0 also. Clicked install :D

Classy 04-06-2003 10:08 PM

is there a way to make it so when your posting people have the option to click the bbcode? Just like they do for [img] or [code]?
Hope this makes sense. Thanks.

Blindchild02 04-07-2003 06:50 PM

yea, i also want that... like in the newthread, so your able to click a button, like the IMG button and HTML button

also.. a problem i have, is that not all the images work with [thumb] ... why is that? o_O

Classy 04-07-2003 06:51 PM

I'm thinkin it has to do with the code in functions.php .... not sure though

Blindchild02 04-07-2003 06:54 PM

i think its only jpg's that dont work, cuz gif does :|

boutwell 04-08-2003 03:00 PM

I wish I had found this months ago...great hack Z :)

However, I think the install .txt file may have gotten trunked somehow. This is all I am getting:

PHP Code:

This hack adds a new tag to your forums that will allow you to post images
in the form of a thumbnail
.

The tag allows you to post pictures in the form of a thumbnailLarge images
can 
throw off the page, and the tag will scale the picture down to an 80x60
thumbnail preserving its original length 
and width ratio and turn it into a
hyperlink that you can click on 
and see the full image in a new browser window.
If 
the image being thumbnailed is smaller than 80x60it will show up as is

This tag is identical to the IMG tag.

Tables affectednone
Templates affected
none
Files affected
admin/functions.php

Check out this link 
for a demo: [url]http://www.ls1.com/forums/showthread.php?s=&threadid=276879[/url]

*************************************************************************************
NoteThis tag does not resize the actual pictureIt just displays them at a smaller
      scale
It will not help with bandwidth preservation.
*************************************************************************************


In admin/functions.php
Look 
for:

        
$bbcode=str_replace("{""{"$bbcode); // stop people posting replacements in their posts

  
return censortext($bbcode);

And 
change it to:

        
$bbcode=str_replace("{""{"$bbcode); // stop people posting replacements in their posts
        
$bbcode=preg_replace("/\[thumb\](\r\n|\r|\n)*((http|https):\/\/([^;<>\(\)\"".iif($allowdynimg,"","!\*\?\&")."]+)|[a-z0-9\/\\\._\- ]+)\[\/thumb\]/esiU""dothumb('\\2')"$bbcode);
  return 
censortext($bbcode);

########################################

In admin/functions.php

look 
for:

// ###################### Start phphighlite #######################

Add the following directly above it:

// ###################### Start dothumb #######################
function dothumb($code) {

  
$img_info = @getimagesize($code);
  if(
$img_info[0]) {
    if((
$img_info[0] <= 80) and ($img_info[1] <= 60)) {
      
$code "<a href=\"$code\" target=\"_blank\"><img src=\"$code\"></a>";
    }
    else {
      
$xratio $img_info[0] / 80;
      
$yratio $img_info[1] / 60;
      
$factor $xratio;
      if(
$yratio $xratio) {
        
$factor $yratio;
      }
      
$xsize intval($img_info[0] / $factor);
      
$ysize intval($img_info[1] / $factor);
      
$code="<a href=\"$code\" target=\"_blank\"><img src=\"$code\" width=\"$xsize\" height=\"$ysize\" border=\"3\"></a>";
    }
  }

  return(
$code);


I did this and the tag isn't working...don't I have to add a BBcode via the admin control panel as well?

Zzed 04-08-2003 05:11 PM

It is the complete file. That's all you need to do. No need to add anything through the admin CP. ;)

boutwell 04-08-2003 05:41 PM

Ok I am at a total loss here Zzed...are there any other hacks that this doesn't cooperate with with perhaps? Everything is set correctly but it still only shows the URL of the image I post for some reason.

Here is my test post:

http://dev.ringofdestiny.com/vb/show...php?threadid=2

Here is the contents of that post:

{thumb}http://205.214.94.176/~rod/images/emperor.jpg{/thumb} (with brackets of course)

If you are really bored I will mail you the info for my dev board and you can take a look :)

Zzed 04-08-2003 05:57 PM

Quote:

Today at 11:41 AM boutwell said this in Post #54
Ok I am at a total loss here Zzed...are there any other hacks that this doesn't cooperate with with perhaps? Everything is set correctly but it still only shows the URL of the image I post for some reason.

Here is my test post:

http://dev.ringofdestiny.com/vb/show...php?threadid=2

Here is the contents of that post:

{thumb}http://205.214.94.176/~rod/images/emperor.jpg{/thumb} (with brackets of course)

If you are really bored I will mail you the info for my dev board and you can take a look :)

Sure. Hit me... :D

My Email is: edwink@seebeyond.com

boutwell 04-08-2003 06:18 PM

Info is on its way Zzed. Thanks bud :)

Zzed 04-08-2003 06:58 PM

Everything is working fine. ;)

Blindchild02 04-08-2003 07:52 PM

:( .jpg's dont work for me either :'(

zzed do u have AIM or MSN??

Zzed 04-08-2003 08:20 PM

Quote:

Today at 01:52 PM Blindchild02 said this in Post #58
:( .jpg's dont work for me either :'(

zzed do u have AIM or MSN??

I worked with boutwell and we dicovered that his site is not able to get the length and width dimensions for certain pictures.

The dothumb() function tries to obtain the XY sizes for the picture and if it is not able to do it, it displays the URL for the picture...

This is how you can debug your code:

In functions.php

Look for:
PHP Code:

  $img_info = @getimagesize($code); 

And replace it with the following:
PHP Code:

  $img_info = @getimagesize($code);
  echo 
"$code <br>";
  echo 
"$img_info[0] <br>";
  echo 
"$img_info[1] <br>"

And you will notice that the length and width information show up blank.

If you want to bypass all the drama you can go the easy route and replace the function dothumb() with the following:
PHP Code:

 
function dothumb($code) {
 
  
$code="<a href=\"$code\" target=\"_blank\"><img src=\"$code\" width=\"80\" height=\"60\" border=\"3\"></a>";
 
  return(
$code);


Of course the only drawback with this is that if you try and thumbnail a smilie, it will actually magnify it. :)

Let me know if this helps...

Blindchild02 04-08-2003 08:21 PM

well i woudl like to talk on AIM or msn plz :(

aim - bc aka blind
msn - starman_02@msn.com

qwertzu 04-10-2003 10:18 AM

Cool
nice hack Zzed
thanks for that great one
i try it right now
:)

qwertzu 04-10-2003 10:49 AM

i've got a little bug it works fine everywhere (post & signs)
exept for one member in his sign it displays only the link but if i put that pic in a post the thumb works :lick:
i'v find the solution by hosting on my server & renaming the pic
here is the original pic i have remove the % and change JPG in jpg http://membres.lycos.fr/seadoo1979/s...io%20sonny.JPG
do you think that's normal ??

and thanks again for this great hack

Zzed 04-10-2003 07:21 PM

qwertzu, that only happens when getimagesize() can not determine the image height and width. :(

And thank you for your kind words. :)

Katman 04-11-2003 08:06 PM

I can't get this to work! It still shows as the original image size. Is there something I'm missing or not doing right? vB 2.2.9

Example:
http://www.tlplanet.com/forums/showt...?threadid=2023

Zzed 04-11-2003 08:28 PM

Quote:

Today at 02:00 PM Katman said this in Post #64
I can't get this to work! It still shows as the original image size. Is there something I'm missing or not doing right? vB 2.2.9

Example:
http://www.tlplanet.com/forums/showt...1965#post21965

You are using the wrong tag. Instead of IMG you need to use THUMB. ;)

I registered and posted a reply to your thread. Check it out. :D

Katman 04-11-2003 08:31 PM

I see that you made it work! Yes, I was using the [*img*] tag, that's the way I understood the hack to work. My mistake, sorry.

I guess my question now is, is there any way to make the IMG tag do this automatically?

Thanks for the help!

Zzed 04-11-2003 08:36 PM

In functions.php:
Look for:
PHP Code:

function bbcodeparse2($bbcode,$dohtml,$dobbimagecode,$dosmilies,$dobbcode)
// parses text for vB code, smilies and censoring

  
global $DB_site,$wordwrap,$allowdynimg$bbuserinfo;

  static 
$smilies,$bbcodes;
  global 
$regexcreated,$searcharray,$replacearray,$phpversionnum

Add the following directly below it:
Code:

$bbcode =  preg_replace("/img\]/i", "thumb]", $bbcode);
This will replace all your IMG tags with THUMB tags. ;)

Katman 04-11-2003 08:41 PM

Do I have to add [ in front of the /img\] and thumb]? Because when I tried it as you have it I received an error.

Parse error: parse error in /home/tlplanet/www/html/forums/admin/functions.php on line 640

Fatal error: Call to undefined function: vbdate() in /home/tlplanet/www/html/forums/admin/sessions.php on line 400

Zzed 04-11-2003 09:03 PM

Hmm, I don't know why the PHP tag mutilated my preg_replace statement.

I have tried this on my board and it worked just fine. :)

Code:

$bbcode =  preg_replace("/img\]/i", "thumb]", $bbcode);

Katman 04-11-2003 09:11 PM

I don't know what it was but I tried it again and now it's working! Thank You! You are the master!

Now the only problem I can see is the images in the signatures, they're linked now, with a border, even after I changed border=1 to 0. :D

Zzed 04-11-2003 09:16 PM

Quote:

Today at 03:05 PM Katman said this in Post #70
I don't know what it was but I tried it again and now it's working! Thank You! You are the master!

Now the only problem I can see is the images in the signatures, they're linked now, with a border, even after I changed border=1 to 0. :D

Thank you kind sir. :)

Please give me a link to a thread containing an image in the sig.

And I am so hurt that you deleted my replies... :laugh::banana:

Katman 04-11-2003 09:18 PM

<a href="http://www.tlplanet.com/forums/showthread.php?threadid=2006" target="_blank">http://www.tlplanet.com/forums/showt...?threadid=2006</a>

Sorry about that, just part of the testing process

Zzed 04-11-2003 09:25 PM

That's because the image is 256x170 which is smaller than your 320x240 image resize. ;)

in dothumb()

Replace this:
Code:

    if(($img_info[0] <= 80) and ($img_info[1] <= 60)) {
      $code = "<a href=\"$code\" target=\"_blank\"><img src=\"$code\"></a>";
    }

with this:
Code:

    if(($img_info[0] <= 80) and ($img_info[1] <= 60)) {
      $code = "<a href=\"$code\" target=\"_blank\" border=\"0\"><img src=\"$code\"></a>";
    }

Excpet that instead of 80 and 60 you would be using 320 and 240 in the if statement. ;)

Katman 04-11-2003 09:30 PM

I did that originally.

Forget it, I see, Duh, you added the border=0

Code:

// ###################### Start dothumb #######################
function dothumb($code) {

  $img_info = @getimagesize($code);
  if($img_info[0]) {
    if(($img_info[0] <= 320) and ($img_info[1] <= 240)) {
      $code = "<a href=\"$code\" target=\"_blank\"><img src=\"$code\"></a>";
    }
    else {
      $xratio = $img_info[0] / 320;
      $yratio = $img_info[1] / 240;
      $factor = $xratio;
      if($yratio > $xratio) {
        $factor = $yratio;
      }
      $xsize = intval($img_info[0] / $factor);
      $ysize = intval($img_info[1] / $factor);
      $code="<a href=\"$code\" target=\"_blank\"><img src=\"$code\" width=\"$xsize\" height=\"$ysize\" border=\"0\"></a><br><font size=\"-2\">(click for larger image)</font>";
    }
  }

  return($code);
}
// ###################### End dothumb #######################


Zzed 04-11-2003 09:34 PM

Cool. :)

Katman 04-11-2003 09:35 PM

Nope, still linked with border. I'm going to add border=\"0\" to every href tag! :)

Damn, still there.

Got it! Needed to add border=0 to
Code:

<img src=\"$code\" border=\"0\"></a>";

Zzed 04-11-2003 09:39 PM

Quote:

Today at 03:29 PM Katman said this in Post #76
Nope, still linked with border. I'm going to add border=\"0\" to every href tag! :)

Nope, just hit reload. ;) The border will go away. ;)

Katman 04-11-2003 09:40 PM

OK, I'm done now, it's all good! Thanks for the quick helpful replies!

Zzed 04-11-2003 09:47 PM

You're very welcome. :)

Larry@IOG 04-11-2003 09:59 PM

Quote:

Today at 05:57 PM Zzed said this in Post #69
Hmm, I don't know why the PHP tag mutilated my preg_replace statement.

I have tried this on my board and it worked just fine. :)

Code:

$bbcode =  preg_replace("/img\]/i", "thumb]", $bbcode);

Didnt work for me, showed the image as a link rather than a thumbnail


Larry


All times are GMT. The time now is 04:53 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01985 seconds
  • Memory Usage 1,875KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (10)bbcode_code_printable
  • (5)bbcode_php_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete