Re: Auto resize images
hmmm, ....so what is "Litebox" ? Another xxxxbox
You are not logged in. Please login or register.
PunBB Forums → PunBB 1.2 modifications, plugins and integrations → Auto resize images
hmmm, ....so what is "Litebox" ? Another xxxxbox
When I looked at Highslide and Thickbox?, I would have said they were more intensive, rather than faster than Lightbox or Greybox. That's just be my personal opinion, though.
Tjalve,
I have to come back to this - your mod works wonderful this far, but I encountered a small problem.
If somebody insert an image with that tag, which is smaller that my preset width, it get resized to that width and of course distorted.
Is there a way to tell - lets say: "if the image is largen than 680 px width, than resize - if it is smaller, keep the original size"
Thank's
I have found a solution!
I combined Tjalve's script and the script out of the "add Lightbox" Mod from http://www.punres.org/desc.php?pid=282 by Robert h
Now I can set the max width for images to be shown with the img_tag
If wider than my postarea it will be displayed resized with a link to be opened in original size - or (if set) with Lightbox
If smaller or exactly as my postarea it will be displayed in original size.
And, if using Lightbox, you can set the max width of the image to be opened with Lightbox - lets say bigger than 800 pixel width has not to be displayed with Lightbox, but resized and with a link to be opened in original size....
Replace the original img_tag in parser.php with this. If not using Lightbox you have to delete the Lightbox parts in this mod.
// ************************************************************************************************************************************* //
//********************** MOD extra Image Tag for bigger Pictures *****************//
function handle_img_tag($url, $is_signature = false)
{
global $lang_common, $pun_config, $pun_user;
$img_tag = '<a href="'.$url.'" onclick="window.open(this.href); return false;"><'.$lang_common['Image link'].'></a>';
if ($is_signature && $pun_user['show_img_sig'] != '0')
$img_tag = '<img class="sigimage" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
else if (!$is_signature && $pun_user['show_img'] != '0')
{
if (@fclose(@fopen($url, "r")))
{
$imagehw = GetImageSize($url);
$width = $imagehw[0];
$height = $imagehw[1];
$img_tag = '<center><img class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" /></center>';
if ($width > 680) //+++ this is your desired max width of images - also to be set inside the img_tag +++++++++++++++//
{
//+++++ img_tag with Lightbox - delete if not using Lightbox +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
$img_tag = '<center><a href="'.$url.'" rel="lightbox"><img width="680" class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" /></a></center>';
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
//+++++ without Lightbox ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
//$img_tag = '<center><img width="680" class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" /> <br> This image has been resized, click <a href="'.htmlspecialchars($url).'">here</a> to view the full-sized image.</center>';
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
}
//++++++++++ you can use this to set a width limit for images to be show with Lightbox - delete if not using Lightbox +++++++++++++++++++//
if ($width > 800) //+++ max. width of images to be show with Lightbox - wider images will be shown resized and with link ++++//
{
$img_tag = '<center><img width="680" class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" /> <br> This image has been resized, click <a href="'.htmlspecialchars($url).'">here</a> to view the full-sized image.</center>';
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
}
else
{
$img_tag = '<strong>error: image ' . $url . ' cannot be loaded.</strong>';
}
}
return $img_tag;
}
// ******************************************************************************** //
// ************************************************************************************************************************************* //
no64
Your code doesn't work.
error: image http://www.ndesign-studio.com/file/wall … 80x800.jpg cannot be loaded.
well, yes and no :S ....the problem is the "fclose" and "fopen" which is included in the original code of the Lightbox integration mod. Your server has to support that - php.ini fopen has to be set to "on"
I recognise the same problem with this when I was changing the server, but after talking with my hoster and changing the settings it worked again.
Maybe somebody else has a better solution for not using "fopen" and "fclose".
Btw. Your Blog looks great, did you made the theme by yourself?
Could you tell me what plugin you use for the "links" page and for the "contact" page, please?
you mean tjalves code?
Yes, of course, that one just changes the img tag and "my" code is a combination of that code and a lightbox integration....
...and the code from the lightbox integration doesn't work if your server don't have those setting to allow "fopen" and "fclose"
why not do it via css? find the part that out puts the img
add class
go to css set height and width... of that class.
so no matter how big it will only display the set height and width.
i did that when i made a simple address book system small db to sql with contact images....
Q
yes, but what is if the image is smaller thant set in the CSS - is it going to be scaled up?
yes it will be ... hummmmm....
someone could always write a if then or else statement for file size.... to link it to a css.
oh well just a thought.
q
..what about this:
http://www.punres.org/desc.php?pid=358
Haven't testet it yet, but it may be useful for certain purposes
PunBB Forums → PunBB 1.2 modifications, plugins and integrations → Auto resize images
Powered by PunBB, supported by Informer Technologies, Inc.