![]() |
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.
|
All times are GMT. The time now is 01:50 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:
|