![]() |
Check for valid linked image and resize if too large
I hate it when users link to images that are really large and cause the layout of the site to become all distorted. It's also annoying to see the image placeholder and the red "X" whenever the site hosting an image is unavailable.
This check will check the width of a linked image and if it's wider than the size you would like to allow, it will add a width attribute to the <img> tag so it will be resized. If the image is not available on the linked site, then it will display a message saying the linked image is currenty unavailable. It only requires an edit to admin/functions.php. Open functions.php and find the following line: PHP Code:
PHP Code:
Replace $img_size[0]> 400 & width=\"400\" with the your max width and that's it. |
What if we have "Allow Dynamic URL for [img] tags?" set to no? Can we use this for the regular image tags? And is there a way to do this for attached images, too?
|
A great hack idea, the same questions as Bo.
|
It's Boofo, not Bo.
|
Yes this will work regardless if you have Dynamic URL's turned on or off.
As for attached images you can already specify a max width in vB options in the admin control panel. |
But that only works in the Admin CP if you have view images turned on. I have it turned off. I am using Slynderdale's Show Image attachments hack and I am looking for a way to do it with that. Any ideas? ;)
|
After installing ALL image tags became <linked image unavailable>
|
The getimagesize requires PHP 4.0.5.
Comment out ob_start() and ob_end_clean() and see if it is returning an error message. |
I am running PHP 4.3.1 and I am also getting the <linked image unavailable> error.
|
Using getimagesize WILL increase server load as the image needs to be downloaded, then MySQL needs to check the image size, and resize it on the fly if it's too big, and then display it... just so you know.
|
This doesn't work for me at all :(
If i change: if ($img_size[0]> 400) { to if ($img_size[0]< 400) { It works but that's the other way ;) It just don't resize with if ($img_size[0]> 400) { Any ideas ? |
Quote:
|
good idea but doesnt work good....
|
Quote:
|
Thanks a lot CVNMagic , but i'm not an expert coder .. I look for an hack that resize on-the-fly linked images not images as attachmate , anyone know that a hack working already exist ??
|
Hi,
I use the following file as the solution. I'm sure someone here can make this better but it's a start. In the zip file is a image.js and a html file as an example. Greetz |
Sorry , but I'm not sure to have understood.
|
Not understood what mate?
|
Quote:
|
Just look at the html file.
See the code used. Paste <script type="text/javascript" src="http://www.yoursite.com/image.js"></script> in the header of your vbulletin site Paste <SCRIPT language=javascript>check_images();</SCRIPT> in the footer of your vbulletin site Upload the image.js to your server and that's about it |
Cool ! I'll try it .
Thanks. |
i saw this option on an other dutch forum (not vbulletin) isnt is posible to make the hack like this :
http://forum.fok.nl/showtopic.php/447356 so when u click on it that it opens in a popup with a clickable close on it :) this is what QiQme is meaning |
Quote:
I put this : PHP Code:
PHP Code:
Why not work ?? QiQme , what does it mean this piece of code? PHP Code:
|
..anybody ? :(
|
I am in the dark too XXman, i would love to see this hack work properly too.
The example over at: http://forum.fok.nl/showtopic.php/447356 Is exaclty how it should be done, although i really have no clue how they have done that, or how to incorporate it into vbulletin. So if someone could help us out i would be eternally gratefull! |
Quote:
|
In the attachement ( https://vborg.vbsupport.ru/showpost....3&postcount=16 ) you can see that it works.
There's just nothing more to say about it i think. |
Hey thanks!
That works perfect, well almost it does, the only problem i have now is that the pop-up has some white space above the enlarged image. Strange, although the pop-ups on the the example page: http://forum.fok.nl/showtopic.php/447356 Doesn't have that ugly whitespace. Any clues? Hmm, i just checked and i think they used an image.php document, with unknown contents... Also on your example zip file, the image in the pop-up is cropped somehow, it doesn't show the complete image... Argh :) |
Quote:
|
QiQme thats a great idea and it works great on IE, but not on Netscape/Opera/Mozilla. Is there any code fix for this?
|
I was just thinking, if you can automatically add this onload function below in the IMG tag, the resizing of the imageswill crossbrowser friendly.
Quote:
Can somebody try to get this working properly pehaps? I am not a script wizard :( |
yea im also looking for the fix
i tried it myself but i cant seem to find it |
works great! thanks!!!
|
Quote:
|
Quote:
Any fix? Works fine in IE but not Mozilla. |
All times are GMT. The time now is 04:44 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|