The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Comments |
#52
|
|||
|
|||
Is it possible to have this resize modification only affect bbcode parsing when it is called from the vBadvanced news.php module?
I'd like to do something like the following, but I'm not sure of the exact syntax and whether or not I can determine the page/script name within class_bbcode.php. EDIT: Nevermind, I got it working 5 seconds after I posted with the following: Code:
if (THIS_SCRIPT == 'adv_index'){ $navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : ''; if (stristr($navigator_user_agent, "msie")) { return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" alt="" style="width: expression(this.width > 640 ? 480 : true);" /></a>'; } else { return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" alt="" style="max-width: 730px;" /></a>'; } } else { return '<img src="' . $link . '" border="0" alt="" />'; } |
#53
|
||||
|
||||
OK guys,
Here is the last revision of my code. Finaly got it working: Code:
/* Start hack Image RESIZE */ // Check to see if image exists $link = str_replace(" " , "%20", $link); $link = str_replace("&" , "%26", $link); // Get host url name for fsockopen to see if server is reachable $img_host=str_replace('http://','',$link); $img_host=substr($img_host,0,strpos($img_host,'/')); // Check is server is reachable and timeout in 5 seconds if not if (@fclose(@fsockopen($img_host, 80, $fsockerr1, $fsockerr2, 5))) { // Check if image is on server if (@fclose(@fopen("$link", "rb"))) { // Check image size and if oversize, change bbtag $img_width = getimagesize($link); if ($img_width[0] > 600) { $navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : ''; if (stristr($navigator_user_agent, "msie")) { return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" alt="' . $vbphrase['click_for_larger_image'] . '" style="width: expression(this.width > 600 ? 600 : true);" /></a>'; } else { return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" alt="' . $vbphrase['click_for_larger_image'] . '" style="max-width: 600px;" /></a>'; } } else { return '<img src="' . $link . '" border="0" alt="" />'; } } else { // Image not found return '<table border="1" cellpadding="2" id="image_found"><tr><td><FONT color="#FF0000">' . $vbphrase['image_link_broken'] . '</font></td></tr></table>'; } } else { // Server is down return '<table border="1" cellpadding="2" id="image_found"><tr><td><FONT color="#FF0000">' . $vbphrase['image_server_down'] . '</font></td></tr></table>'; } /* End hack Image RESIZE */ // /* Original code: return '<img src="' . $link . '" border="0" alt="" />'; */ Check if the database server is online Check if the image is available Check the width of the image If > 600 width, resize to 600 and place a link under it to click for the orginal image It doesn't touch the image when =< 600 width. The problem with not being able to cope with spaces or ampersands in the url is solved. If you are gonna use this, be sure to add the three phrases. You can costumize the width that you want as limit for resizing by changing the three instanses of "600" in the code to the limit you want. I don't want to take credit for this code because I did nothing else than changing the existing code that was allready there Enjoy |
#54
|
|||
|
|||
seems to make the pages take alot longer to load...or is it just me?
|
#55
|
|||
|
|||
Quote:
|
#56
|
||||
|
||||
Quote:
That's because each picture is validated and that's a extra process in opening the page. Pages with no pictures of just a few will not be affected. |
#57
|
||||
|
||||
Quote:
With "under it" I meant that when you hoover over the picture you see a resize message and the cursor changes into a hand. Then you can click the picture for a larger image. If you want this text litteraly under the picture, you might try this: Find: Code:
return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" alt="' . $vbphrase['click_for_larger_image'] . '" style="width: expression(this.width > 600 ? 600 : true);" /></a>'; } else { return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" alt="' . $vbphrase['click_for_larger_image'] . '" style="max-width: 600px;" /></a>'; } Code:
return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" alt="' . $vbphrase['click_for_larger_image'] . '" style="width: expression(this.width > 600 ? 600 : true);" /><br><br>' . $vbphrase['click_for_larger_image'] . '</a>'; } else { return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" alt="' . $vbphrase['click_for_larger_image'] . '" style="max-width: 600px;" /><br><br>' . $vbphrase['click_for_larger_image'] . '</a>'; } Again, don't forget to add the vbphrases, or substitute in above code ' . $vbphrase['click_for_larger_image'] .' for hard coded text like "Click for larger image". |
#58
|
||||
|
||||
Quote:
Find in the code of post #52 the next code: Code:
// Image not found return '<table border="1" cellpadding="2" id="image_found"><tr><td><FONT color="#FF0000">' . $vbphrase['image_link_broken'] . '</font></td></tr></table>'; } } else { // Server is down return '<table border="1" cellpadding="2" id="image_found"><tr><td><FONT color="#FF0000">' . $vbphrase['image_server_down'] . '</font></td></tr></table>'; } Code:
// Image not found return '<img src="http://aquatic-photography.com/pics/noimage.gif" border="0" alt="" />'; } } else { // Server is down return '<img src="http://aquatic-photography.com/pics/noserver.gif" border="0" alt="" />'; } |
#59
|
|||
|
|||
Your code is good, but I have a lot of pictures in my forums. It took some seconds to saw the thread while the pictures are checked before the thread would be visible. The user think my forum is slow. Any chance to modify this, because I know the original code was f*cking fast
|
#60
|
||||
|
||||
Sorry A-handreas, as I said before I'm not realy a coder. I just combined two pieces of code to make another one and succeeded (to my own suprise) to make that work.
I lowered the time-out variable on the @fsockopen() command from 5 to 2. That might speed things up a little. But I'm not aware of php code that could do those checks faster. Maybe some *real* coders know a quicker way. |
#61
|
|||
|
|||
so it this hack like what you get on invision power boards?
when someone posts and image linked from another site/gallery it will resize the image so it keeps the thread structure aligned? if so, how do i insert this code? whats the final code that works? |
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|